我的問題是,當我使用innererHtml binding-angular2刪除所有樣式屬性。這對我很重要,因爲在我的任務中 - html是在服務器端用所有樣式生成的。 例子:Angular2 innerHtml binding刪除樣式屬性
@Component({
selector: 'my-app',
template: `
<input type="text" [(ngModel)]="html">
<div [innerHtml]="html">
</div>
`,
})
export class App {
name:string;
html: string;
constructor() {
this.name = 'Angular2'
this.html = "<span style=\"color:red;\">1234</span>";
}
}
但在DOM我只看到1234,本文不紅。
http://plnkr.co/edit/UQJOFMKl9OwMRIJ38U8D?p=preview
謝謝!
非常酷的決議!非常感謝你! – user2921406
謝謝!真的很有用的答案。 – codelovesme
請注意,您可以使用以下命令向Ionic添加新管道:'離子管道MyPipe' – makinbacon