相关疑难解决方法(0)

ElementRef安全风险角度2

为什么ElementRef不安全,如果是这样,我们可以使用什么呢?

我一直在使用这个ElementRef来查看或观看特定的html标签,然后在初始化之后作为特定宽度发送,但是如果这打开了安全风险我将不会使用它,并且说实话我不明白为什么角度2个团队在他们的框架中允许这种安全漏洞.

什么是安全和最好的技术?我的测试组件如下:

        import { Component, OnInit } from '@angular/core';

        @Component({
          selector: 'app-standard',
          template: ` <button type="button" #buttonW></button>`,

        })
        export class standardComponent implements OnInit {

          name: string = 'app-standard';
          viewWidthButton: any;

          @ViewChild( 'buttonW' ) elButtonW: ElementRef; 


          constructor() { 

            this.viewWidthButton = this.elButtonW.nativeElement.offsetWidth;
            console.log ('button width: ' + this.viewWidthButton);
          }

          ngOnInit() {
          }

        }
Run Code Online (Sandbox Code Playgroud)

Angular 2页面参考:

https://angular.io/docs/ts/latest/api/core/index/ElementRef-class.html

angular

6
推荐指数
1
解决办法
1829
查看次数

检测并警告用户有关大写锁定的信息

如何在大写锁定打开时检测和警告用户(或者没有)打字稿中的工具提示样式(角度4.2.2)?也许有一些keyup事件,或者像toUpperCase()JS一样.

angular

4
推荐指数
2
解决办法
3590
查看次数

标签 统计

angular ×2