我试图在组件中注入原始输入html
<input [(ngModel)]='person.firstName' />
我正在关注DomSanitizer指南 :In RC.1 some styles can't be added using binding syntax
到目前为止它注入了html,但是模型绑定中断...
这是我的dummy.component.html:
<div *ngFor="let comp of myinputs">
<div [innerHTML]="comp | safeHtml"></div>
</div>
和dummy.component.ts
export class DummyForm {
@Input() formName: string;
myinputs: string[];
Inputs: DummyRenderClass[];
person = {
firstName: "Tom",
lastName: "Hanks",
};
constructor() {
this.GenerateInputs();
}
GenerateInputs(): void {
for (var i = 0; i < this.Inputs.length; i++){
var component = this.Inputs[0].Component;
this.myinputs.push(component);
}
}
}
输入[0] .Component是带有html代码的字符串
它生成输入字段,但它不会绑定到模型。关于绑定的任何想法?