我的问题是,当我使用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