我想改變文本框的背景顏色,當有人在角度4中的文本框中輸入顏色時。但它不工作。我正在使用Visual Studio代碼。這裏是我的代碼:更改文本框的背景顏色
<input type="text" ngModel="myColor" ng-style="{background-color: myColor}">
我想改變文本框的背景顏色,當有人在角度4中的文本框中輸入顏色時。但它不工作。我正在使用Visual Studio代碼。這裏是我的代碼:更改文本框的背景顏色
<input type="text" ngModel="myColor" ng-style="{background-color: myColor}">
試試這個:
<input type="text" [(ngModel)]="myColor" [ngStyle]="{'background-color': myColor}">
角語法應爲[(ngModel)
]和[ngStyle]
,
<input type="text" [(ngModel)]="myColor" [ngStyle]="{'background-color': myColor}">
爲什麼downvote這裏? – Sajeetharan
這是不正確的語法使用ngClass,嘗試以下代碼:
<input type="text" ngModel="myColor" [ngStyle]="{'background-color': myColor}">
[ngStyle] = 「{背景色:myColor}」 是角(2+)方法 –