简体   繁体   中英

Angular2 forms - access value in ngIf

I have a <select #type > . Now I need to reference the value of this select later on in the template inside a ngIf, but how can I do so?

Tried *ngIf='type.value!="Category"' and it doesn't seem to do the trick..

Could you bind the select to your model and then reference the model element?

<select [(ngModel)]="type">
  <!-- Options -->
</select>
<div *ngIf="type !== 'Category'">
</div>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM