Angularjs의 다른 Firebase 개체로 Firebase 목록 필터링
-
21-12-2019 - |
문제
그래서 내가 바인딩하는 다른 Firebase 객체를 사용하여 필터링하고 싶은 큰 Firebase 목록을 가지고 있습니다.내 '검색'개체를 Firebase에 바인딩하지 않으면 FireBase를 필터링하지만 Firebase에 바인딩 할 때 결과가 0이됩니다.
내 컨트롤러 :
.controller('TestResultsCtrl', ['$scope', 'syncData', '$routeParams', '$firebase', '$filter', function($scope, syncData, $routeParams, $firebase, $filter) {
$scope.id = $routeParams.id;
syncData('tests/' + $routeParams.id).$bind($scope, 'test');
syncData('tests/' + $routeParams.id + '/specs').$bind($scope, 'search');
syncData('diagnoses').$bind($scope, 'all_diagnoses');
}])
.
내 견해 :
<a href="" ng-repeat="diagnoses in all_diagnoses | orderByPriority | filter:search" class="list-group-item">{{diagnoses.title}}</a>
.
샘플 '검색'개체 :
{
"constant": true,
"intermittent": true,
"localized": true,
"referred": false,
"region": "hip"
}
.
'진단'Firebase 객체 / 목록의 샘플 :
{
"constant": true,
"intermittent": true,
"localized": true,
"referred": false,
"region": "hip",
"title": "Hip Osteoarthritis"
},
{
"constant": true,
"intermittent": false,
"localized": false,
"referred": true,
"region": "neck",
"title": "Whiplash"
}
.
어떻게 이것을 올바르게 필터링 할 수 있습니까?
... 그리고 미리 감사드립니다!
해결책
$ BIND에서 반환 된 객체가 각 ANTULALLY가 필터링하려는 여러 $ 메소드를 포함하는 것입니다.
다음과 같이 시도해보십시오 ...
syncData('tests/' + $routeParams.id + '/specs').$bind($scope, 'searchDirty');
$scope.$watch('searchDirty', function (search) {
$scope.search = angular.fromJson(angular.toJson(search));
});
.
이것은 모든 $ 메소드 / 값을 제거하고 데이터의 원시 값을 반환합니다.
제휴하지 않습니다 StackOverflow