[英]Nativescript how to write HTML in typescript like document.write()
基本上我想根據用戶輸入在不同的行/列位置生成特定數量的標簽,但我找不到任何告訴如何從 .component.ts 文檔寫入 .component.html 文檔的地方。 我基本上想使用類似 document.write() 但對於 nativescript 的東西。
使用插值(由{{...}}
)從模板中的組件插入數據:
成分:
export class AppComponent {
name = 'Angular';
labels = [
{
id: '1',
name: '',
},
{
id: '2',
name: '',
},
{
id: '3',
name: '',
},
];
public onKey(event: any) {
for (const label of this.labels) {
label.name = event.target.value;
}
}
}
模板(HTML):
<div class="divTable">
<div class="divTableBody">
<ng-container *ngFor="let label of labels">
<div class="divTableRow">
<div class="divTableCell">{{ label.id }}</div>
<div class="divTableCell">{{ label.name }}</div>
</div>
</ng-container>
</div>
</div>
<p>Type here:</p>
<input (keyup)="onKey($event)">
工作示例: Stackblitz
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.