SafeValue必须使用[property] = binding:

The*_*eal 14 angular

我的输入中出现以下错误:

SafeValue must use [property]=binding: http://www.myurl.com (see http://g.co/ng/security#xss)
Run Code Online (Sandbox Code Playgroud)

我在我的组件中做了:

this.myInputURL = this.sanitizer.bypassSecurityTrustUrl('http://www.myurl.com');
Run Code Online (Sandbox Code Playgroud)

在我的模板中:

Share URL: <md-input [value]="myInputURL" type="text"></md-input>
Run Code Online (Sandbox Code Playgroud)

怎么了?

Asa*_*lah -4

我也发生了同样的事情。这是因为跨域限制。只需使用嵌入版本链接https://www.youtube.com/embed/video-ID而不是常规网址https://www.youtube.com/watch?v=Video-ID

是的,您仍然会收到相同的警告,但您现在可以忽略它,因为一切都会按预期进行。