2013-09-24 60 views
0

簡單的CRUD應用程序,客戶端列表視圖和詳細視圖。我希望列表視圖在服務器上排序,所以我應該在客戶端FireBase引用上設置優先級。將客戶端名稱綁定到優先級

angular.module('MyApp') 
    .controller 'ClientsDetailCtrl', ($scope, $routeParams, angularFire) -> 
    fb = new Firebase('https://myurl.firebaseio.com/clients/' + $routeParams.id) 

    angularFire(fb, $scope, 'client') 

    $scope.$watch('client.name', (newValue) -> 
     fb.setPriority(newValue) if newValue != undefined) 

每次client.name變化,我設置的火力點REF的優先級。但是,當我回到列表頁面時,優先級爲空。我認爲這是因爲改變名稱調用引用上的set(),這會清除優先級。

什麼是最簡單的方法來完成client.name的優先級設置?我可以嘗試使用$ timeout,但是當client.name以外的值被修改時會被覆蓋。

+1

這是AngularFire中的一個已知錯誤:https://github.com/firebase/angularFire/issues/116 - 敬請期待! – Anant

回答

0

顯然這是現在在AngularFire中修復的。