在 ng-change 上获取包含模型

Get encompassing model on ng-change

很抱歉标题混乱,问题很简单。

我有一个 $scope.users 变量。我 ng-repeat 他们并为每个用户创建一个输入,直到 属性 有效。在此输入的 ng-change 上,我想发送关于我的用户服务的更新请求。如何在我的 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
  });
}

将用户传递给函数

<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.
}