12&e
其中
<select id="dpname" [(ngModel)]="nameSelectedVal">
<option value="0">Select one...</option>
<option *ngFor="let name of names" value = {{name.code}}>
{{name.definition}}
</option>
</select>
<button class="btnView">VIEW</button>
所以,默认情况下我将nameSelectedVal值设置为&#34; -1&#34;显示&#34;选择一个......&#34;那就是我想要禁用按钮,直到用户选择除了&#34之外的其他一些值;选择一个...&#34;然后在选择与&#34不同的其他值时启用它;选择一个...&#34;。
我在类文件中设置names = [
{
"code": -1,
"definition": "Select one..."
},
{
"code": 1,
"definition": "Affiliates"
},
{
"code": 2,
"definition": "Asia/Pacific"
},
{
"code": 3,
"definition": "EMEA"
},
{
"code": 4,
"definition": "North America"
},
{
"code": 5,
"definition": "Latin America"
},
{
"code": 6,
"definition": "Web"
}
]
;
谢谢!
答案 0 :(得分:4)
我只想为按钮添加[disabled]="nameSelectedVal === '-1'"