2015-11-06 83 views
2

我正在嘗試使用智能表。我按照這裏提供的說明:http://lorenzofox3.github.io/smart-table-website/ 所以根據這些說明,我需要做的就是運行bower install angular-smart-table,然後添加模塊angular.module('myApp',['smart-table']並添加到您的角度應用程序中。這裏是我的角度應用:'smart-table'模塊不可用

# pwd 
/var/www/html 
# cat meanVoyApp.js 
var app = angular.module("meanVoyApp", ['smart-table']); 

但現在當我打開我的標記我在瀏覽器控制檯中看到這些錯誤:

Uncaught Error: [$injector:modulerr] Failed to instantiate module meanVoyApp due to: 
Error: [$injector:modulerr] Failed to instantiate module smart-table due to: 
Error: [$injector:nomod] Module 'smart-table' is not available! You either misspelled the module name or forgot to load it. If registering a module ensure that you specify the dependencies as the second argument. 
http://errors.angularjs.org/1.3.14/$injector/nomod?p0=smart-table 

我沒拼錯,所以我想我「忘記」加載它。那麼我如何加載它?我怎麼知道它是否已經加載,而其他問題呢?

謝謝!

回答

5

您是否記得在index.html中添加對腳本的引用?

<script src="[directoryOfModule]/smart-table.js"></script> 
+0

是的,工作。謝謝! –

2

智能表附帶一些js文件。我認爲你沒有加載之前,你的meanVoyApp.js加載。使用chrome開發人員工具網絡面板來識別java腳本是否正確加載。

使用下面的代碼的app.js負載

<script src="http://lorenzofox3.github.io/smart-table-website/bower_components/angular-smart-table/dist/smart-table.js"></script> 
2

使用

bower install angular-smart-table --save 

和一些好的一飲而盡或咕嚕構建工具配置(例如自耕農)之前,會自動將其添加到您的索引。 HTML。

+0

這有幫助,因爲在我的情況下,bower做了一些額外的工作(在資產中添加了lib),這是強制性的,但是我手動在index.html中添加了 Mindaugas

0

看看你的構建過程。

如果你使用ngBoilerplate Kickstarter的,則需要添加下列行: 「供應商/角智能表/ DIST /智能table.min.js」

內部vendor_files build.config的部.js文件。