小编Dav*_*e E的帖子

与angularfire相当的firebaseRef.push()是什么?

在下面的非angularfire伪代码中,我希望firebase生成一个用于推送新数据的密钥.

var ref = Firebase(...);
var newref = ref.push({"blah":"blah"});
var autoKey = newref.name();
Run Code Online (Sandbox Code Playgroud)

我尝试通过angularfire与绑定模型做同样的事情,但它只是给我错误的对象没有push()方法,类似于这个问题.当数据类型是数组时,他让它工作.

如何获得我在常规Firebase(非angularFire)中使用对象自动键看到的漂亮行为?

firebase angularfire

9
推荐指数
1
解决办法
4349
查看次数

使用FireBaseAuthClient与AngularJS时出现"错误:$ apply已在进行中"

我正在尝试在AngularJS范围内记录登录用户,但在页面首次加载时收到错误.

单击"登录"似乎工作,但然后注销保释与相同的"$ apply has in progress"错误.

我期待我只是误解了它是如何$apply工作的,有人可以帮忙吗?

更新:

如果我将if (user)部分包装$apply()成如下,它可以无缝地工作.

var auth = new FirebaseAuthClient(ref, function(error, user) {
    if (user) {
        $scope.$apply(function(){ $scope.user = user; });
        console.log(user);
    } else if (error) {
        // I can't vouch for this, haven't tested it
        $scope.$apply(function(){ $scope.user = null; });
        console.log(error);
    } else {
        $scope.user = null;
        console.log("logged out");
    }
});
Run Code Online (Sandbox Code Playgroud)

原始代码:

app.js:

var app = angular.module('app', ['firebase']);
Run Code Online (Sandbox Code Playgroud)

controller.js:

app.controller('Login', ['$scope', 'angularFire',
function($scope, angularFire) {
    $scope.loginstatus …
Run Code Online (Sandbox Code Playgroud)

angularjs firebase angularfire

7
推荐指数
1
解决办法
4348
查看次数

标签 统计

angularfire ×2

firebase ×2

angularjs ×1