0
假設我檢索的HTML代碼的[字符串]從MongoDB的如角打字稿innerHTML的輸入組件結合
["<div class=list-group-item><span><label>Enter text</label> : <input type =text placeholder=value [(ngModel)]=text0 index=gen > </span> </div>",
"<div class=list-group-item><span><label>Enter text</label> : <input type =text placeholder=value [(ngModel)]=text1 index=gen > </span> </div>"]
,我處理我消毒,並想使之成爲全功能的形式!
我的html代碼:
<p>
DATA:
{{this.id}}
</p>
<span *ngFor="let item of this.code;let x= index;"><div [innerHTML]="sanitizer.bypassSecurityTrustHtml(this.code[x])" ></div>
{{this.item}}<br>
WORK GOdDAMMIT!!: {{text0}}
</span>
我硬編碼text0,看它是否決定工作!
現在,你們可以給我一個關於如何訪問ngModel值的基本例子,所以我可以做到嗎?
在AngularJS(V1.6)我的管理符合所謂的外部模塊做綁定,HTML編譯
任何一個小例子或這樣將是非常有益!
如果你想看看我的component.ts,在這裏:
@Component({
selector: 'app-form-show',
templateUrl: './form-show.component.html',
styleUrls: ['./form-show.component.css'],
providers: [FormShowService]
})
export class FormShowComponent implements OnInit {
private id:string;
private code:string;
//private htmlCode :HTML
constructor(
private http: Http,
private router: Router,
private route : ActivatedRoute,
private sanitizer: DomSanitizer
) {
}
ngOnInit(){
//console.log(this.Code)
console.log(this.route.params['value'].id);
this.id=this.route.params['value'].id
this.getID();
}
getID(){
let jsonData : JSON;
jsonData=JSON.parse('{"data" :"'+ this.id +'"}');
return this.http.post('/api/getInfo', jsonData).subscribe(
res => {res.json();
console.log(res.json());
let resProc = res.json();
console.log(resProc);
this.code=resProc[0].script;
console.log(this.code);
});
}
}
謝謝!