ng-repeat 在 angularjs 中具有数组的对象
ng-repeat on object having array in angularjs
我正在使用 angularjs,下面是我的代码,我需要输出为
红色
绿色
黄色
显示为数组
['red','green','yellow']
请帮忙。
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.6.9/angular.min.js">
</script>
<body ng-app="myApp" ng-controller="myCtrl">
<div ng-repeat="product in products | filter: { color: true }">
{{product.type}}
</div>
</body>
var app = angular.module("myApp", []);
app.controller("myCtrl", function($scope) {
$scope.products = [
{ id: 1, name: 'test', color: true, type:['red','green','yellow'] },
{ id: 2, name: 'bob', color: false },
{ id: 3, name: 'john', color: false },
{ id: 4, name: 'rock', color: false },
{ id: 5, name: 'mercy', color: false },
{ id: 6, name: 'jack', color: false }
];
});
请帮忙
**谢谢我得到答案,如果有更好的选择。请分享 **
<div ng-repeat="product in products | filter: { color: true }">
<div ng-repeat ="type in product.type">
{{type}}
</div>
</div>
我正在使用 angularjs,下面是我的代码,我需要输出为
红色
绿色
黄色
显示为数组
['red','green','yellow']
请帮忙。
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.6.9/angular.min.js">
</script>
<body ng-app="myApp" ng-controller="myCtrl">
<div ng-repeat="product in products | filter: { color: true }">
{{product.type}}
</div>
</body>
var app = angular.module("myApp", []);
app.controller("myCtrl", function($scope) {
$scope.products = [
{ id: 1, name: 'test', color: true, type:['red','green','yellow'] },
{ id: 2, name: 'bob', color: false },
{ id: 3, name: 'john', color: false },
{ id: 4, name: 'rock', color: false },
{ id: 5, name: 'mercy', color: false },
{ id: 6, name: 'jack', color: false }
];
});
请帮忙
**谢谢我得到答案,如果有更好的选择。请分享 **
<div ng-repeat="product in products | filter: { color: true }">
<div ng-repeat ="type in product.type">
{{type}}
</div>
</div>