模块'smart-table'不可用

时间:2015-11-06 19:58:34

标签: javascript angularjs smart-table

我正在尝试使用智能表。我按照此处提供的说明操作:http://lorenzofox3.github.io/smart-table-website/ 因此,根据这些说明,我需要做的就是运行bower install angular-smart-table然后添加然后将模块angular.module('myApp',['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

我没有拼错,所以我想我“忘了”加载它。那么如何加载呢?如何判断它是否已经加载,还有其他问题?

谢谢!

4 个答案:

答案 0 :(得分:5)

您是否记得在index.html中添加对脚本的引用?

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

答案 1 :(得分:2)

Smart-table附带一些js文件。我认为您之前没有加载到您的meanVoyApp.js加载。使用chrome developer tool network panel来识别java脚本是否正确加载。

在app.js加载

之前使用以下代码
<script src="http://lorenzofox3.github.io/smart-table-website/bower_components/angular-smart-table/dist/smart-table.js"></script>

答案 2 :(得分:2)

使用

bower install angular-smart-table --save

并且一些好的gulp或grunt构建工具配置(例如yeoman)会自动将其添加到index.html。

答案 3 :(得分:0)

看看你的构建过程。

如果您使用ngBoilerplate kickstarter,则需要添加以下行: &#39;供应商/角智能表/ DIST /智能table.min.js&#39;

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