[英]Angular 2 Bind a variable to a header in html
我正在嘗試將變量綁定到標題以顯示當前步驟(即“您在第1步的10”中)。 我有它為textarea工作,無法弄清楚為什么它不適用於標題。
private mainStepText: String = "Welcome";
<div class="mainWindow">
<textarea [(ngModel)]="mainStepText"></textarea>
</div>
到目前為止我所擁有的是什么
private testLabel: String = "This is a test label for html";
<div class="test">
<h3 class="labelName" [(ngModel)]="testLabel"></h3>
</div>
現在它拋出一個錯誤
“錯誤錯誤:未捕獲(在承諾中):錯誤:沒有指定名稱屬性的表單控件的值訪問器錯誤:沒有用於具有未指定名稱屬性的表單控件的值訪問器”
而不是標簽中的ngModel。 做就是了:
<h3 class="labelName">{{testLabel}}</h3>
並在組件中設置testLabel
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.