【发布时间】:2013-09-24 14:36:14
【问题描述】:
简单的 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 更改时,我都会在 FireBase ref 上设置优先级。但是,当我返回列表页面时,优先级为空。我认为发生这种情况是因为更改名称会调用 set() 引用,这会清除优先级。
为 client.name 设置优先级的最简单方法是什么?我可以尝试使用 $timeout,但是当 client.name 之外的值被修改时,它会被覆盖。
【问题讨论】:
-
这是 AngularFire 中的一个已知错误:github.com/firebase/angularFire/issues/116 - 敬请期待修复!
标签: angularjs firebase angularfire