升级AngularFire导致脚本停止工作? [英] Upgrading AngularFire causes scripts to stop working?
问题描述
下面的脚本是从火力使用angularfire,火力点和角一个简单的读。问题是,当我从0.7.1升级到AngularFire .0.8.0脚本完全停止工作,我不知道我做错了吗?
The following script is a simple read from firebase using angularfire, firebase, and angular. The issue is that when I upgrade AngularFire from 0.7.1 to .0.8.0 the script completely stops working and I'm not sure what I'm doing wrong?
<body>
<section ng-app="myapp" ng-controller="MyController">
<div ng-repeat="item in data">
<h3 ng-cloak>{{item.title}}</h3>
</div>
</section>
<script>
angular.module("myapp", ["firebase"])
.factory("FirebaseService", ["$firebase", function ($firebase) {
var furl = "https://helloworldtest.firebaseio.com/";
var ref = new Firebase(furl);
return $firebase(ref);
}])
.controller('MyController', ["$scope", "FirebaseService", function ($scope, firebaseservice) {
$scope.data = firebaseservice
}]);
此机智它configuraiton正常工作:
Wit this configuraiton it works fine:
<script src='https://cdnjs.cloudflare.com/ajax/libs/angular.js/1.2.6/angular.min.js'></script>
<script src='https://cdn.firebase.com/js/client/1.0.17/firebase.js'></script>
<script src='https://cdn.firebase.com/libs/angularfire/0.7.1/angularfire.min.js'></script>
,但与此,它不工作
but with this, it doesn't work:
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.3.0-beta.17/angular.min.js"></script>
<script src="https://cdn.firebase.com/js/client/1.0.18/firebase.js"></script>
<script src="https://cdn.firebase.com/libs/angularfire/0.8.0/angularfire.min.js"></script>
也许这是最好不要升级。
Perhaps it's better not to upgrade.
- 查看工作的jsfiddle: http://jsfiddle.net/chrisguzman/z8Lpj63w/
- 见不工作的jsfiddle(带angularfire升级): http://jsfiddle.net/chrisguzman/z8Lpj63w/
- See working JSFiddle: http://jsfiddle.net/chrisguzman/z8Lpj63w/
- See not working JSFiddle (with angularfire upgrade): http://jsfiddle.net/chrisguzman/z8Lpj63w/
推荐答案
在你的控制器做的事: -
In your controller do:-
$scope.data = firebaseservice.$asArray(); //or .$asObject
或做它在您的服务: -
Or do it in your service:-
return $firebase(ref).$asObject(); //or .$asObject
Demo
我从来没有使用火力地堡,但看起来这是用来改善功能的重大更改,的在这里找到它
I have never used Firebase but seems like this is a breaking change introduced to improve the functionality, Found it here
在previous的版本,当AngularFire绑定初始化加载火力地堡的数据。改进后的API提供了两种方法,在不同的格式加载数据。这些方法是$ asObject()和$ asArray()。
In previous versions, Firebase data loaded when the AngularFire binding initialized. The improved API provides two methods that load data in different formats. Those methods are $asObject() and $asArray().
更新的基础上,从评论加藤
Update based on comment from Kato
下面是更改日志中注明的变化新版本。它指出引进许多重大更改,所以我猜你可以预期的一样,直到1.0的稳定版本已经完成。这里是href=\"https://www.firebase.com/docs/web/libraries/angular/api.html\" rel=\"nofollow\">官方的API文档的
Here is the change log stating the changes in the new version. It states the introduction of many breaking changes, so i guess you can expect the same until 1.0 stable release is done. Here is the official api documentation.
这篇关于升级AngularFire导致脚本停止工作?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!