我正在尝试使用另一个表提供的数据来填充表格 表一包含每个项目的复选框的所有数据 表2应仅包含表1中已检查过的项目。
我可以看到' Checked' value gets设置为true,但不起作用(我在表2中始终获得所有数据)
$ scope.data
对象{key:" 3",value:" c",$$ hashKey:" 006",checked:true}
期望的结果:
<span>Table One</span>
<div ng-controller="checkBoxCtrl">
<table width="400" border="1">
<tr ng-repeat="data in tableOne" id="item{{data.key}}">
<td width="20px">
<input type="checkbox" ng-model="data.checked">
</td>
<td>{{data.key}}</td>
<td>{{data.value}}</td>
</tr>
</table>
<br>
<span>Table Two</span>
<table width="400" border="1">
<tr ng-repeat="data in tableOne | filter: data.checked==true">
<td>{{data.key}}</td>
<td>{{data.value}}</td>
</tr>
</table>
var app = angular.module('myApp', []);
function checkBoxCtrl($scope){
$scope.tableOne=[
{key: '1', value: 'a'},
{key: '2', value: 'b'},
{key: '3', value: 'c'},
{key: '4', value: 'd'}
];
};
答案 0 :(得分:1)
只需删除其中一个等号。
<tr ng-repeat="data in tableOne | filter: checked=true">
答案 1 :(得分:0)
这是过滤属性的语法....基本上它是一个对象,但我想在角度方面它可能被认为是一个表达式。我不是100%肯定如何用文字来定义它......但是它有效
<tr ng-repeat="data in tableOne | filter: {checked:true}">
的 DEMO 强>