Javascript 如果在数组内重复ng,如何使用ng?
我有一个数组或颜色=[“红色”、“白色”、“金色”、“黑色”]; 我试着做一些类似下面的代码Javascript 如果在数组内重复ng,如何使用ng?,javascript,angularjs,angularjs-ng-repeat,Javascript,Angularjs,Angularjs Ng Repeat,我有一个数组或颜色=[“红色”、“白色”、“金色”、“黑色”]; 我试着做一些类似下面的代码 <span ng-repeat="color in item.colorOptions" ng-init="color"> <lable ng-if="'Red' == {{color}}"> This is Red..</lable> <lable ng-if="'Black' == {{color}}"> This is Black..
<span ng-repeat="color in item.colorOptions" ng-init="color">
<lable ng-if="'Red' == {{color}}"> This is Red..</lable>
<lable ng-if="'Black' == {{color}}"> This is Black..</lable>
</span>
这是红色的。。
这是黑色的。。
如果喜欢上面的代码,为什么我不能使用ng?使用ng if或ng show/hide的原因和替代方法是什么?应该是
<span ng-repeat="color in item.colorOptions" ng-init="color">
<lable ng-if="color === 'Red'"> This is Red..</lable>
<lable ng-if="color === 'Black'"> This is Black..</lable>
</span>
这是红色的。。
这是黑色的。。
此处假定为item.colorOptions=[“红色”、“白色”、“金色”、“黑色”];