我想点击Angular 2.0中的标签,重定向到生成HTML的链接。我目前的编码是这样的。
import { Component, Pipe, PipeTransform } from '@angular/core';
import { DomSanitizer } from '@angular/platform-browser';
@Component({
moduleId: module.id,
selector: 'my-pictures',
template:'
<div class="embed-responsive embed-responsive-16by9">
<iframe class="embed-responsive-item" width="300" height="100" [src]="'https://www.youtube.com/embed/CM6rVEAAQ3k' | safe" allowfullscreen> </iframe>
</div>
`,
})
@Pipe({ name: 'safe' })
export class PicturesComponent implements PipeTransform {
constructor(private sanitizer: DomSanitizer) { }
transform(url) {
return this.sanitizer.bypassSecurityTrustResourceUrl(url);
}
}
它表示参数'url'隐式具有'any'类型。请告诉我当前代码中的错误。另外,指导在Angular 2中包含iframe的正确方法。