var displayyears = [];
$scope.Joinyear=function(display){
$scope.yeardisplay=display;
if (displayyears.indexOf(display) == -1) {
$scope.selected_class[display] = "selected";
displayyears.push($scope.yeardisplay);
}
else{
$scope.selected_class[display] = "";
displayyears.splice($scope.displayyears.indexOf(display),1);
}
It works but not in correct fashion.Suppose If i have array like this [2008,2009,2010,2011]. Now I remove value from array in random manner(in between like 2009) means it remove value 2008 only...How to remove value from array in random fashion using Angular JS
I believe your mistyped the $scope in this line:
displayyears.splice($scope.displayyears.indexOf(display),1);
Should be:
displayyears.splice(displayyears.indexOf(display),1);