I've just started playing with Angular, and I'm having a hard time understanding certain things here. I wanted to set up a list of products, which belong to different categories. Some products are in the same category, like so :
$scope.products = [
{'name': 'Product 1', 'cat':'Cat 1'},
{'name': 'Product 2', 'cat':'Cat 2'},
{'name': 'Product 3', 'cat':'Cat 2'},
{'name': 'Product 4', 'cat':'Cat 3'},
{'name': 'Product 5', 'cat':'Cat 3'},
{'name': 'Product 6', 'cat':'Cat 2'},
];
I was able to create a <select> which merges the same categories in order to avoid duplicates, thanks to the unique filter from AngularUI. Here is the code :
<select ng-model="query" ng-options="c.cat for c in products | unique:'cat'">
<option value="0">Default</option>
</select>
<ul>
<li ng-repeat="c in products | filter:query">
{{c.name}}
</li>
</ul>
I want to display the results in a list according to the category I've selected. But when I try to do so, the only product returned in the list will be the first one inside the category. I've created a Fiddle with my problem: http://jsfiddle.net/F7Hvq/3/.
Any help would be really appreciated!