Dav*_*e E 9 firebase angularfire
在下面的非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)中使用对象自动键看到的漂亮行为?
如果要使用Object并具有自动生成的键,请使用a上的add方法angularFireCollection.例如:
function ExampleController($scope, angularFireCollection) {
var url = 'https://angularFireExample.firebaseio-demo.com/';
$scope.examples = angularFireCollection(url);
$scope.addExample = function(ex) {
$scope.examples.add(ex);
};
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
4349 次 |
| 最近记录: |