【发布时间】:2017-12-19 10:01:07
【问题描述】:
我正在尝试使用 Angular 2+ 向选择框添加显示/隐藏行为,所以基本上我有:
<select>
<option disabled selected>Flow progres</option>
<option *ngFor='let flow of flows'>{{flow}}</option>
</select>
<div [hidden]="true">
<p>The flow progress is on going</p>
</div>
和.ts:
export class ProductListComponent implements OnInit{
flows = ["Passed",'Waiting','In Progres',' Failed'];
}
so when "in progress" option will be selected I want to show that hidden div, otherwise the div will be hidden for the other options.
【问题讨论】:
-
在 select 上使用 [ngModel] 并将 div 上的条件设置为 [hidden]="yourngmodelvariable!=='In Progress'"
-
尝试将
*ngIf用于in progress并在选择时设置[ngModel] -
@Vivz 把它作为评论来获得你的分数 ;) ty!
-
好的,我会把它作为答案发布:)
标签: html angular typescript angular2-forms