0
아래의 .json 파일에서 내 검색 필드를 가져 와서 데이터를 필터링 할 수 없습니다. 검색 필드에 입력을 시작하면 모든 항목이 사라집니다.각도 필터가 여러 값으로 작동하지 않습니다
다음은 내 데이터베이스로 작동하는 json 파일입니다.
[{
"id": 1,
"userId": 1,
"firstName": ["Jack", "text"],
"lastName": ["Rackum", "text"],
"phone": ["33221122", "tel"]
}, {
"id": 2,
"userId": 1,
"firstName": ["Ellery", "text"],
"lastName": ["Queen", "text"]
}, {
"id": 3,
"userId": 1,
"firstName": ["Minnie", "text"],
"lastName": ["Mouse", "text"]
}]
그리고 여기 내 의견은 프런트 엔드
<div class="input">
<input type="text" placeholder="Søg" ng-model="query.$">
<i class="icon"></i>
</div>
<div class="item" ng-repeat="child in children | filter:query">
<img class="image" src="images/children/1.jpg">
<div class="content" >
<div class="header">
<a>
{{ child.firstName[0] }} {{ child.lastName[0] }}
</a>
</div>
</div>
</div>
용 파일 및 내 controllers.js이 파일
angular.module('ContactsApp')
.controller('ListController', function ($scope, Contact) {
$scope.children = Contact.query();
$scope.fields = ['firstName', 'lastName'];
$scope.firstname = ['firstName'];
$scope.lastname = ['lastName'];
$scope.phone = ['phone'];
});
그리고 마지막으로 내 공장은 파일
angular.module('ContactsApp')
.factory('Contact', function ($resource) {
return $resource('/api/child/:id', { id: '@id' }, {
'update': { method: 'PUT' }
});
});
". $"없이 "쿼리"만 사용하면 안됩니다. – byrdr
". $"을 사용하면 여러 값을 사용할 수 있다는 문서를 읽었습니다. 제거하면 여전히 작동하지 않습니다. –
Contact가 데이터를 보유하고있는 서비스라고 가정하고 있는데, query() 메소드는 무엇을 참조합니까? – byrdr