2017-03-10 70 views
0

我正在嘗試將ng-rollbar添加到我的RoR + AngularJS項目中。堆棧是:ruby 2.3.1p112,Rails 4.2.6和angularJS 1.4.12。 依照指示操作,我拼命地跑了命令:RoR + AngularJS注入器模塊未能實例化模塊

涼亭安裝NG-翻車--save

這裏後,我的bower.json:

{ 
"name": "dsl-generated dependencies", 
"dependencies": { 
"foundation-sites": "~6.2.3", 
"jquery-ujs": "~1.2.1", 
"angular": "~1.4.12", 
"angular-sanitize": "~1.4.12", 
"angular-cookies": "~1.4.12", 
"angular-route": "~1.4.12", 
"angular-resource": "~1.4.12", 
"angular-local-storage": "~0.2.7", 
"angular-scroll-glue": "~2.0.7", 
"components-font-awesome": "~4.6.3", 
"pusher": "~3.1.0", 
"pusher-angular": "~0.1.9", 
"angular-payments": "git://github.com/laurihy/angular-payments#9643191f23", 
"angular-moment": "~0.10.3", 
"angular-xeditable": "~0.2.0", 
"zInfiniteScroll": "~1.1.4", 
"motion-ui": "~1.2.2", 
"angular-toastr": "~1.7.0", 
"angular-elastic": "~2.5.1", 
"angular-material": "~1.0.9", 
"angular-google-analytics": "~1.1.7", 
"angular-animate": "~1.4.12", 
"angular-aria": "~1.4.12", 
"angular-messages": "~1.4.12", 
"ng-rollbar": "^1.9.2" 
}, 
"resolutions": { 
    "angular": "~1.4.12" 
} 

}

然後,我創建了一個名爲app/assets/javascripts/config/ngrollbar.js的滾動條獲取initiallize的文件:

app.config(function(ngRollbarProvider) { 
    RollbarProvider.init({ 
    accessToken: "<MY-APPLICATION-TOKEN>", 
    captureUncaught: true, 
    payload: { 
    environment: 'production' 
    } 
}); 
}); 

並補充ngrollbar到應用程序/資產/ Javascript角/配置/ app.js:

var app = angular.module('chat', 
    [ 
    'pusher-angular',`enter code here` 
    'luegg.directives', 
    'ngRoute', 
    'templates', 
    'angularPayments', 
    'angularMoment', 
    'xeditable', 
    'zInfiniteScroll', 
    'toastr', 
    'monospaced.elastic', 
    'ngMaterial', 
    'angular-google-analytics', 
    'tandibar/ng-rollbar', 
    ]).run( ["$rootScope","$http","amMoment","editableOptions","editableThemes","$mdSidenav",'Analytics','ngrollbar', function($rootScope , $http , amMoment , editableOptions , editableThemes , $mdSidenav , Analytics , ngrollbar) { ... }]); 

在應用程序/資產/ Javascript角/控制器/ chat.js:

app.controller("ChatController", [$scope","$rootScope","$http",'$pusher','$location','$routeParams','userProfile','toastr','flash','ngrollbar', function($scope , $rootScope , $http , $pusher , $location , $routeParams , userProfile , toastr , flash , ngrollbar) {...}]); 

而在應用程序/資產/ javascripts/application.js我已添加: //= require ng-rollbar

當我嘗試運行我的應用程序時,我收到此消息在瀏覽器控制檯:

Error: [$injector:modulerr] Failed to instantiate module chat due to: 
[$injector:unpr] Unknown provider: ngRollbarProvider 

我敢肯定,這不是NG-翻車的具體問題,我很想念在添加新的模塊,我的回報率+ AngularJS應用程序,但我能過程中的一些步驟弄清楚我做錯了什麼。我已經檢查過涉及這個錯誤的任何以前的問題,但我找不到任何涉及使用angularJS和Ruby On Rails的人。

回答

0

一個月後,我問回購問題的部分,我得到一個令人難以置信的快速回答: https://github.com/tandibar/ng-rollbar/issues/30

它只是一個命名混亂:你必須注入「翻車」而不是「ngrollbar 」。

app.controller("ChatController", [$scope","$rootScope","$http",'$pusher','$location','$routeParams','userProfile','toastr','flash','Rollbar', function($scope , $rootScope , $http , $pusher , $location , $routeParams , userProfile , toastr , flash , Rollbar) {...}]); 

改變一些NG-翻車和ngRollbar到翻車後,一切都工作就像一個魅力。