我想我過濾存儲項目數據庫,但我不希望使用過濾器這樣的:AngularJS:在NG-重複過濾項不使用過濾器
<li ng-repeat="post in posts | filter: { etat: 'enCours' } ">
此行過濾所有的職位其中etat ='enCours',但這導致我幾個問題,因爲我有幾個ng重複,我不能使用$索引。
我願做這樣的事情:
<li ng-repeat="post in postsEnCours">
對於使用此功能:
This line give me all the post store in my database
$scope.posts= Posts.query();
$scope.postsEnCours = $scope.posts.filter(function(item, index) {
return item.etat === 'enCours';
})
但沒有出現你知道爲什麼嗎?
你的Posts.query函數是同步的嗎?如果不是,那麼你應該在查詢完成後過濾。 – kokeksibir
是的我認爲這是問題,但我不知道如何告訴函數等待查詢完成 – Vodet