简体   繁体   English

Angular2形式-ngIf中的访问值

[英]Angular2 forms - access value in ngIf

I have a <select #type > . 我有一个<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? 现在,我稍后需要在ngIf模板中引用此select的值,但是我该怎么做呢?

Tried *ngIf='type.value!="Category"' and it doesn't seem to do the trick.. 尝试过*ngIf='type.value!="Category"' ,它似乎并没有解决问题。

Could you bind the select to your model and then reference the model element? 您能否将选择绑定到模型,然后引用模型元素?

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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