2015-12-28 68 views
3

我已經建立使用角和火力地堡的應用程序,這是工作,直到我決定改變目錄和從頭構建它來解決一些兼容性問題(使用引導程序)。現在,當我嘗試去我的網址我得到以下錯誤:AngularJS未知的提供程序錯誤(火力地堡&AngularFire)

Error: [$injector:unpr] Unknown provider: $firebaseArrayProvider <- $firebaseArray

我已經通過類似的問題搜索,並沒有發現,解決我的問題的任何答案。我嘗試過通過涼亭和鏈接來安裝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); 
}]); 
+0

您需要包括模塊嘗試之前註冊它們,即包括前angularfire * *'app.js' –

+0

我的腳本是按照下面的順序,我仍然收到錯誤。我列出他們的方式有問題嗎? Angular/AngularRoute/Firebase/AngularFire/app.js/editor.js – tjq

回答

3

你忘了包括新模塊「杉EBASE」在app.js

app.js

angular.module('myApp', [ 
    'ngRoute', 
    'myApp.editor', 
    'firebase' 
]). 

編輯:

包括從@Explosion丸答案:

的index.html,你也應該將腳本src =「app.js」移動到最後一行,以便在註冊之前先加載所有需要的js文件。

+0

得到它的工作!非常感謝,我想我一定錯過了一件非常簡單的事情。但是,在my ** editor.html **頁面中,儘管開發工具告訴我該css文件已被正確加載,但樣式仍不顯示。這是由於我所做的任何更改嗎?如果需要,我可以發佈小提琴。 – tjq

+0

很高興幫助。小提琴會很好!由於事情發生在其他文件上,我需要在代碼上檢查它 – Quy