I have the template:
我有模板:
<div ng-repeat="CableFilterName in CableFilterNames">
<fieldset>
<legend>{{CableFilterName.filterName}}</legend>
<ul id="">
<li ng-repeat="filterValue in CableFilterName.filterValues">
<input type="checkbox"/> {{filterValue}}
<!-- <select> -->
</li>
</ul>
</fieldset>
</div>
where filterValue
in nested ng-repeat
has several different values. So question is how to define what is current filterValue
-value and depending on it use checkbox or select or any arbitrary HTML ?
在嵌套的ng-repeat中,filterValue有几个不同的值。问题是如何定义什么是当前filtervalue值根据它使用复选框或选择或任意的HTML ?
UPD:
乌利希期刊指南:
filterValues = ['Cable System','Electrical', 'Lighting'];
1 个解决方案
#1
3
To have a kind of if statement, you can use the ngSwitch directive in AngularJS :
要有一种if语句,可以使用AngularJS中的ngSwitch指令:
http://docs.angularjs.org/api/ng.directive:ngSwitch
http://docs.angularjs.org/api/ng.directive ngSwitch
For example on your ngRepeat loop :
比如你的ngRepeat循环:
<div ng-switch on="filterValue">
<div ng-switch-when="value1">//Do what you want when "value1"</div>
<div ng-switch-when="value2">//Do what you want when "value2"</div>
...
<div ng-switch-default>//Do what you want by default</div>
</div>
I Hope it's what you want, I don't really understand what you try to achieve.
我希望这是你想要的,我真的不明白你想要达到的目标。
#1
3
To have a kind of if statement, you can use the ngSwitch directive in AngularJS :
要有一种if语句,可以使用AngularJS中的ngSwitch指令:
http://docs.angularjs.org/api/ng.directive:ngSwitch
http://docs.angularjs.org/api/ng.directive ngSwitch
For example on your ngRepeat loop :
比如你的ngRepeat循环:
<div ng-switch on="filterValue">
<div ng-switch-when="value1">//Do what you want when "value1"</div>
<div ng-switch-when="value2">//Do what you want when "value2"</div>
...
<div ng-switch-default>//Do what you want by default</div>
</div>
I Hope it's what you want, I don't really understand what you try to achieve.
我希望这是你想要的,我真的不明白你想要达到的目标。