尝试使用ngDialog时出现未定义的错误

时间:2014-03-31 14:44:50

标签: angularjs

我使用bower来安装ngDialog模块 - 请参阅here我试图在我的app.js文件中使用其余的依赖项实例化模块,如下所示:

var app = angular.module('myApp', [
    'ngResource',
    'ngRoute',
    'ngCookies',
    'ui.bootstrap',
    'ngDialog',
    'myApp.services',
    'myApp.directives',
    'myApp.controllers',

]);

但是当我构建应用程序并尝试在浏览器中打开它时,我得到一个空白页面,并显示错误:

Uncaught Error: [$injector:modulerr] Failed to instantiate module myApp due to:
Error: [$injector:modulerr] Failed to instantiate module ngDialog due to:
Error: [$injector:nomod] Module 'ngDialog' is not available! You either misspelled the ...

有人可以提出建议吗?

2 个答案:

答案 0 :(得分:3)

此问题表明您未在index.html文件中包含该javascript。

您有一个定义ngDialog的javascript文件,请确保它已被浏览器加载。

答案 1 :(得分:1)

您的控制器可能没有将ngDialog作为依赖项,因此在运行时无法使用...请检查您是否执行以下操作:

app.controller('YourController', function($scope, ..., ngDialog) {
    ...
});