My code is outputting:
- red
- green
Using the model of $scope.selected = '123' how can I edit it to only output:
- red
Here's my view:
<body ng-controller="MainCtrl">
<ul>
<li ng-repeat="item in items">
{{item.color}}
</li>
</ul>
</body>
Here's my controller:
var app = angular.module('plunker', []);
app.controller('MainCtrl', function($scope) {
$scope.selected = '123';
$scope.items = {
'123': {
color: 'red',
quantity: 3
},
'456': {
color: 'blue',
quantity: 7
}
};
});
I tried using a filter with selected but didn't have any luck.
itemsan array, then can use filter and property in html based on predicateselected