Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/443.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/angularjs/21.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/ant/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 如果在数组内重复ng,如何使用ng?_Javascript_Angularjs_Angularjs Ng Repeat - Fatal编程技术网

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=[“红色”、“白色”、“金色”、“黑色”];