2014-09-01 53 views
5

我遇到此錯誤:Uncaught錯誤:[$ injector:unpr]未知提供者:eProvider < - e成功部署後到Heroku的

我採用了棱角分明的社會共享BTW:https://github.com/djds4rce/angular-socialshare

去除run功能和模塊名稱djds4rce.angular-socialshare不會導致錯誤,但我很喜歡,對Fb的共享。

//= require_self 
//= require_tree ./angular 

MyApp = angular.module("MyApp", ["ui.router", "ngCsv", "ui.bootstrap", "ngResource", "templates", "angularFileUpload", "ngSanitize", "ngCookies", "textAngular", "djds4rce.angular-socialshare"]).run(function($FB){ 
    $FB.init('1438666983087556'); 
}); 

任何想法?謝謝。

回答

6

Rails的minifies的JS,所以你必須使用一個不同的語法:

MyApp = angular.module("MyApp", ["ui.router", "ngCsv", "ui.bootstrap", "ngResource", "templates", "angularFileUpload", "ngSanitize", "ngCookies", "textAngular", "djds4rce.angular-socialshare"]); 

MyApp.run(['$FB', function($FB){ 
    $FB.init('1438666983087556'); 
}]); 
+0

非常感謝。我會記住這個@apneadiving – 2014-09-01 18:06:43

2

那是正確的。我不得不把coffescript文件更改爲

@HomeCtrl = ['$scope', '$location', ($scope, $location) -> 
    $scope.things = ['Angular', 'Rails 4.1', 'Working', 'Together!!'] 
] 

,以使其發揮作用。注意'$ scope','$ location'

+0

爲什麼需要這個?爲什麼這個語法不起作用:'angular.module('App')。controller「CommentsFormCtrl」,($ scope,$ routeParams,$ http,CommentService) - >' – Kaspar 2014-12-29 12:11:08

相關問題