我一直在使用Angular和Firebase构建应用程序,它一直运行良好,直到我决定更改目录并从头开始构建它以修复一些兼容性问题(使用bootstrap)。现在当我尝试访问我的URL时,会出现以下错误:
Error: [$injector:unpr] Unknown provider: $firebaseArrayProvider <- $firebaseArray
我已经查询了类似的问题,并没有找到能解决我的问题的答案。我尝试通过bower安装Angular,通过链接安装Angular,以及链接到较旧版本的AngularFire.js和Firebase.js。下面是涉及每个文件的代码。
index.html
<!DOCTYPE html>
<html lang="en" ng-app="myApp">
<link rel="icon" href="img/favicon.png">
<link rel="stylesheet" href="css/dirty-soda.css">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/font-awesome/4.5.0/css/font-awesome.min.css">
<script src="http://code.angularjs.org/1.4.8/angular.js"></script>
<script src="http://code.angularjs.org/1.4.8/angular-route.js"></script>
<head>
</head>
<body>
<div ng-view></div>
<script src="app.js"></script>
<script src="editor/editor.js"></script>
<script src="https://cdn.firebase.com/js/client/2.2.4/firebase.js"></script>
<script src="angularfire.min.js"></script>
<script src="../src/ace.js"></script>
</body>
</html>
app.js
'use strict';
angular.module('myApp', [
'ngRoute',
'myApp.editor'
]).
config(['$routeProvider', function($routeProvider) {
$routeProvider.otherwise({redirectTo: 'app/editor'});
}]);
editor.js
angular.module('myApp.editor', ['ngRoute'])
.config(['$routeProvider', function($routeProvider) {
$routeProvider.when('/editor', {
templateUrl: 'editor/editor.html',
controller: 'SnippetCtrl'
});
}])
.controller('SnippetCtrl', ['$scope','$firebaseArray','CommonProp', function($scope,$firebaseArray,CommonProp) {
$scope.username = CommonProp.getUser();
var firebaseObj = new Firebase("<Firebase URL>");
$scope.snippets = $firebaseArray(firebaseObj);
}]);
app.js
之前包含angularfire
模块。 - Explosion Pills