我有一个绑定到下拉菜单的ngSwitch用于模型属性。它没有用,所以我尝试对值进行硬编码。仍然不起作用,它同时显示两个div。我究竟做错了什么?如果很明显,请提前道歉,我是Angular2的新手。
我的html模板:
<!-- display closed date if status is closed, otherwise display active date -->
<div ngSwitch="ACTV">
<div class="form-group row" ngSwitchWhen="CLSD">
<label for="closeDt" class="col-md-4 form-control-label text-md-right">
Close Date
<span class="help-block">Required field</span>
</label>
<div class="col-md-4 col-xs-12">
<datetime [timepicker]="false" [(ngModel)]="date2" id="close-date" name="close-date"></datetime>
</div>
</div>
<div class="form-group row" ngSwitchWhen="ACTV">
<label for="issueDt" class="col-md-4 form-control-label text-md-right">
Active Date
<span class="help-block">Required field</span>
</label>
<div class="col-md-4 col-xs-12">
<datetime [timepicker]="false" [(ngModel)]="date2" id="active-date" name="active-date"></datetime>
</div>
</div>
</div>
在npm服务器上的结果:
您正在使用哪个版本的angular2?在最终版本中,对我有用的语法是:
<div [ngSwitch]="someVariable">
<div *ngSwitchCase="value1">...</div>
<div *ngSwitchCase="value2">...</div>
</div>
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句