I have problems to understand how ng-change works. I have a list of user to invite to join an auction. I want to do this with a checkbox. If the user is checked, his name has to be saved into an array. And later i will invite them(i just know how to do this). But i don't understand how to use the checkbox. I did something like this:
<ul class="list-group" ng-repeat="user in users">
<li class="list-group-item" ng-hide="user.name == profile">
<img ng-src="{{user.img}}" class="image2" >
<div class="username"> {{user.name}}</div>
<div class="userrole"> {{user.role}} </div>
<div class="usercompany">{{user.company}}</div>
<input type="checkbox" ng-model="isChecked" ng-change="insertinvited(user.name)">
</li>
</ul>
And in my controller:
$scope.invited = [];
$scope.insertinvited= function (name) {
if($scope.isChecked){
$scope.invited.push(name)
} else {
console.log($scope.invited);
}
};
But this is not working, in the console the array is always empty.