我的问题,当我使用innererHtml绑定时 - angular2删除所有样式属性.这对我来说很重要,因为在我的任务中 - html是在服务器端生成的,具有所有样式.例:
@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>";
}
}
Run Code Online (Sandbox Code Playgroud)
但是在DOM中我只看到1234而且这个文本不是红色的.
http://plnkr.co/edit/UQJOFMKl9OwMRIJ38U8D?p=preview
谢谢!