Here is my code on HTML. I find it on google that I can use this.
<input type="checkbox" ng-true-value="addTitle(cpPortfolioItem)" ng-false-value="removeTitle(cpPortfolioItem)">
Here is my angularJS controller.
$scope.addTitle = function(cpPortfolioItem){
$scope.selectedTitles.push(cpPortfolioItem.id);
console.log('$scope.selectedTitles', $scope.selectedTitles);
};
$scope.removeTitle = function(cpPortfolioItem){
$scope.selectedTitles.splice(cpPortfolioItem.id,1);
console.log('$scope.selectedTitles', $scope.selectedTitles);
};
it doesn't work. I have logged it in console but I can see it neither push or splice the array. Maybe ng-true-value is not a valid directive? Anyone can help me on this? I will really appreciate it.
ng-checkedattribute instead of true & falseng-checkedis an attribute andngCheckedis a boolean, returning true if it's checked, false if it isn't. You can use both ways ( from API ngChecked)