I want to add an active class on click in a list, i tried the following code, but it adds the active class on all my items :/ :
HTML :
Test on the ID of the selected item :
-
{{filters.time}}
JS:
var filters = [
{
'filterId': 1,
'time': 'last 24 hours',
},
{
'filterId': 2,
'time': 'all',
},
{
'filterId': 3,
'time': 'last hour',
},
{
'filterId': 4,
'time': 'today',
},
{
'filterId': 5,
'time': 'yersteday',
}
];
function selectFilter($scope) {
$scope.filters = filters;
$scope.selected = $scope.items[0];
$scope.select= function(item) {
$scope.selected = item;
};
}