Reputation: 905
I apologize for the confusing title, the problem is quite simple.
I have a $scope.users variable. I ng-repeat them and create a input for every user's respective valid until property. On a ng-change on this input I want to send a update request on my User service. How can I get the proper user on my ng-change?
<div class="row" ng-repeat="user in users">
<input type="date" ng-change="setValidUntil" value="{{user.validUntil}}"/>
//...other user properties
</div>
//in appropriate controller
$scope.setValidUntil = function () {
User.update({
'studentNumber': $scope.user.studentNumber, // Missing this!!
'validUntil':validUntil
});
}
Upvotes: 1
Views: 58
Reputation: 1069
Pass the user into the function
<div class="row" ng-repeat="user in users" style="margin-bottom:0.5em">
<input type="date" ng-change="setValidUntil(user)" value="{{user.validUntil}}"/>
//...other user properties
</div>
//in appropriate controller
$scope.setValidUntil = function (data) {
//you can update your data like that.
}
Upvotes: 1