【发布时间】:2016-05-19 15:41:28
【问题描述】:
我的文件中有这段代码
<div class="table-responsive">
<table class="table">
<thead>
<tr>
<th><a ng-click="sort('PartnerName')">@TID.Partner</a></th>
<th><a ng-click="sort('StartTID')">@TID.StartTID</a></th>
<th><a ng-click="sort('EndTID')">@TID.EndTID</a></th>
<th><a ng-click="sort('DateBlocked')">@TID.DateBlocked</a></th>
<th><a ng-click="sort('Blocked')">@TID.Blocked</a></th>
</tr>
</thead>
<tbody>
<tr ng-repeat="item in items | orderBy:sortOrder:reverseSort | filter:refine | filter: { 'Blocked': showInactive!==true } as filtered ">
<td>{{ item.PartnerName }}</td>
<td>{{ item.StartTID }}</td>
<td>{{ item.EndTID }}</td>
<td>{{ item.DateBlocked }}</td>
<td> <input type="checkbox" ng-click="UnBlockOne(item);" ng-model="item.Blocked"/></td>
</tr>
<tr ng-if="processed == false" ng-cloak>
<td colspan="5">@TID.Loading</td>
</tr>
<tr ng-if="filtered.length == 0 && processed == true" ng-cloak>
<td colspan="5">@TID.NoResultsFound</td>
</tr>
</tbody>
</table>
</div>
我有这个复选框
<td> <input type="checkbox" ng-click="UnBlockOne(item);" ng-model="item.Blocked"/></td>
在我的控制器中调用此方法
$scope.UnBlockOne = function (item) {
db.UnBlockOne(item, function () {
$scope.GetFilteredList(filter);
$rootScope.processed = true;
});
};
奇怪的是,如果我有一个 ng-model,那么 ng-click 不起作用。
所以,这行得通
<td> <input type="checkbox" ng-click="UnBlockOne(item);" ng-model=""/></td>
这不起作用
<td> <input type="checkbox" ng-click="UnBlockOne(item);" ng-model="item.Blocked"/></td>
我在其他文件中有这样的代码,它工作正常。
【问题讨论】:
标签: angularjs angularjs-ng-click