【问题标题】:Bind client name to priority将客户端名称绑定到优先级
【发布时间】: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 之外的值被修改时,它会被覆盖。

【问题讨论】:

标签: angularjs firebase angularfire


【解决方案1】:

显然这个问题现在在 AngularFire 中得到了修复。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2015-03-07
    • 2014-09-13
    • 1970-01-01
    • 2014-09-01
    • 2013-05-06
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多