【发布时间】:2017-10-23 17:09:45
【问题描述】:
我正在使用Checklist-model 显示一些带有复选框的数据。数据是作为承诺的结果提供的。该列表正在填充,但我想将所有复选框设置为默认选中。我怎样才能做到这一点?
这是我的代码:
datas.getRules().then(
function (resRules)
{
$scope.rules = resRules.data._embedded.rules;
$scope.versionForm.ignoreRule = $scope.rules.map(r => r.id);
console.log($scope.versionForm.ignoreRule);
},
function (resRulesErr)
{
console.log(resRulesErr);
}
);
<table class="table">
<thead>
<tr>
<th>Include</th>
<th>Rule</th>
</tr>
</thead>
<tbody>
<tr ng-repeat="r in rules track by $index">
<td><input type="checkbox" checklist-model="versionForm.ignoreRule" checklist-value="r.id" />
</td>
<td>{{r.expression}}</td>
</tr>
</tbody>
</table>
$scope.versionForm.ignoreRule 打印到控制台时,会显示 [64, 67, 18]。
【问题讨论】:
-
checklist-model指令从何而来? Angular 核心没有这样的指令