Angularjsの別のFirebaseオブジェクトによるFireBaseリストのフィルタリング

StackOverflow https://stackoverflow.com//questions/23050002

  •  21-12-2019
  •  | 
  •  

質問

だから私は私がバインドしている別のFirebaseオブジェクトを使ってフィルタリングしたい大きなFirebaseリストを持っています。Firebaseに「検索」オブジェクトをバインドしない場合は、Filters Not Filtersの場合、Firebaseにバインドするとゼロの結果が返されます。

私のコントローラー:

  .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から返されたオブジェクトには、角度をフィルタリングしようとしているいくつかの$メソッドが含まれています。

このようなものを試してみてください...

syncData('tests/' + $routeParams.id + '/specs').$bind($scope, 'searchDirty');
$scope.$watch('searchDirty', function (search) {
    $scope.search = angular.fromJson(angular.toJson(search));
});
.

これは任意の$メソッド/値を削除し、データのRAW値を返します。

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top