I am new to Angular JS and know basic functionality. I am struggling to use ng-repeat and filter options to get the desired output by non unique keys.
I would like to show the cars in html by color or make categories. so desired result I would like to see is(in this case Color is selected):
Sort by: CarID, Make or **Color**
Blue
Focus
Red
Camry
Mustang
Yellow
LandCruiser
The arrays coming from controller are:
cars: [
{
"carid": 1,
"makeid": 1,
"carname": 'camry',
"color": 'red'
},
{
"carid": 2,
"makeid": 2,
"carname": 'mustang',
"color": 'red'
},
{
"carid": 3,
"makeid": 1,
"carname": 'landcruiser',
"color": 'yellow'
},
{
"carid": 4,
"makeid": 1,
"carname": 'focus',
"color": 'blue'
},
{
"carid": 5,
"makeid": 3,
"carname": 'civic',
"color": 'blue'
}
]
make: [
{
"makeid": 1,
"makeName": 'Toyota'
},
{
"makeid": 2,
"makeName": 'Ford'
},
{
"makeid": 3,
"makeName": 'Civic'
}
]
I tried to use following html but to no work
<div class="car" ng-repeat="car in cars track by color">
<label>{{car.color}}</label>
<div class="subcar" ng-repeat="c in cars filer by car.color">
<label>{{c.carname}}</label>
</div>
</div>
Also with above query, how do I replace color in filter with Make once user click on Make link?