0
나는 고객의 배열을 가지고 있습니다. 각 고객은 Field 개체의 배열을 가지고 있습니다. 배열을 필터링하여 일부 특정 Field를 가진 모든 고객을 얻고 싶습니다. 고객 배열은 그렇게 보입니다. 필터 id에 의해 배열 angularjs의 배열
[{"id":236,
"username":"Tsakos Ntinidis",
"email":"[email protected]",
"fields":[{"id":2,"name":"Entrepreneurship"},
{"id":16,"name":"Sciences (Math, Physics, Chemistry etc)"},
{"id":3,"name":"Engineering"},
{"id":18,"name":"Journalism"}],
"hasVideo":false,
"profileDescription":null,"isNew":false},
{"id":237,
"username":"Nick Brown",
"email":"[email protected]",
"fields":[{"id":1,"name":"IT"},
{"id":16,"name":"Sciences (Math, Physics, Chemistry etc)"},
{"id":18,"name":"Journalism"}],
"hasVideo":false,
"profileDescription":null}]
하고 필드 선택 필드를 채 웁니다 목록
은 다음과 같습니다 배열이 비어있는 내 주요 문제가되고<select ng-model="search.fields.field.id" ng-options="field.id as field.name for field in fields">
</select>
<tr ng-repeat="customer in customers | orderBy:predicate:reverse | filter:search" ng- controller="Controller">
<td class="id">{{customer.id}}</a></td>
<td>{{customer.userName}}</a></td>
</tr>
:
[{"id":1,"name":"Finance"},{"id":2,"name":"Entrepreneurship"},{"id":3,"name":"Engineering"},{"id":4,"name":"Economics"}]
그리고 고객 테이블에 대한 HTML이 있습니다 내가 분명히 여과 한 후에 뭔가 잘못되었다. 는 http://jsbin.com/cozasamusinu/1/edit 변화가 당신의 fileds 배열에 지금
<tr ng-repeat="customer in customers |filter :{fields:search.fields.id}:true">
을
<select ng-model="search.fields.id" ng-options="field.id as field.name for field in fields">
</select>
을 선택하고 reapeater에
언급하지 않으려 고 죄송하지만 다른 매개 변수로도 목록을 필터링합니다 –
@vlad_o에 대해 언급했습니다. http://jsbin.com/cozasamusinu/ 2/편집? – sylwester