我有一个输入栏和一个按钮,像这样。
<div class="notes" ng-repeat="n in notes">
<div class="form-group">
<label>Note Date:</label>
<input type="datetime-local" class="form-control" ng-model="noteDate">
</div>
<div class="button" align="center">
<button type="button" class="btn btn-md btn-primary" ng-click="updateDate(noteDate,$index)">Update</button>
</div>
</div>
这就是... updateDate
功能。
$scope.updateDate = function (dt,i) {
console.log(dt);
if (dt != undefined || dt != null) {
$scope.data[i].closingDate = new Date(dt).toISOString();
dt = null;
}
}
这很好用 但问题是,在给了 date
单项输入 ng-repeat
笔记的值保持不变。我用的是 dt=null
以使循环中的其他项目的值消失,但它没有工作。我怎样才能为其他项目删除这个值?
你需要设置 $scope.noteDate = null
作为变量 dt
实际上并不绑定在 model
noteDate
.