2016-02-13 61 views
0

我想在我的rails項目中使用這個angular-number-picker plugin如何在rails中安裝和使用angularJS插件

我下載了.min.js文件和.js文件,並將其放入插件文件夾中。然後,我也包括在

/global_plugins.js

//= require global/plugins/angular-number-picker/angular-number-picker.min.js 

的JS,然後我也它注入到我的應用程序的依賴

/app.js

var app = angular.module('fotograft', ['ngResource', 'angular-loading-bar', 'cgBusy', 'ngFileUpload', 'MessageCenterModule', 'rails', 'Devise', 'google.places', 'ui.sortable','checklist-model', 
'textAngular', 'angularMoment', '720kb.socialshare', 'ngSanitize', '720kb.tooltips', 'angular-md5', 'angularUtils.directives.dirPagination', 'infinite-scroll', 'datatables', 'datatables.bootstrap', 
'ngResource', 'frapontillo.bootstrap-switch', 'angular-bootstrap-select','angular-number-picker', 'angular-bootstrap-select.extra', 'ngTextTruncate', 'chart.js', 'timer', 'siyfion.sfTypeahead']) 

的問題是當我試圖加載任何頁面時,頁面不會響應。於是,我就查看控制檯和調試,錯誤是

Error: [$injector:modulerr] http://errors.angularjs.org/1.3.16/$injector/modulerr? 

我截斷錯誤消息的其餘部分,因爲他們是那種長,看起來亂碼。

所以,我想問一下我在這裏錯過了什麼?我從作者的網頁上看到,我需要將src添加到html頁面的插件中,但是我不知道應該在哪個頁面中包含它。

如果有任何rails和angularJS開發人員可以幫助我,請欣賞它這裏。非常感謝你。

回答

0

如果仔細檢查您提供的link in the source code,它看起來像您必須註冊的模塊名稱應該是angularNumberPicker而不是angular-number-picker

所以,你希望你的app.js模塊註冊表看起來像這樣:

var app = angular.module('fotograft', ['ngResource', 'angular-loading-bar', 'cgBusy', 'ngFileUpload', 'MessageCenterModule', 'rails', 'Devise', 'google.places', 'ui.sortable','checklist-model', 'textAngular', 'angularMoment', '720kb.socialshare', 'ngSanitize', '720kb.tooltips', 'angular-md5', 'angularUtils.directives.dirPagination', 'infinite-scroll', 'datatables', 'datatables.bootstrap', 'ngResource', 'frapontillo.bootstrap-switch', 'angular-bootstrap-select','angularNumberPicker', 'angular-bootstrap-select.extra', 'ngTextTruncate', 'chart.js', 'timer', 'siyfion.sfTypeahead']);

+0

雅呵!非常感謝。我不知道。我很粗心。 – leo277

+0

適合我們最好的人!如果有疑問並且沒有說明,您可以隨時檢查模塊的源代碼,並查看它的setter模塊名稱。 (包括其記錄不完善) –