Angular模块不可用,即使它'
angular module not available even though it's defined
当我尝试运行下面的代码时,我得到两个错误,说
错误:[$injector:nomod]模块'rooms'不可用!你要么拼错模块名或忘记加载它。如果注册了模块确保您将依赖项指定为第二个论点。
错误:[$injector:modulerr]实例化失败[$injector:nomod]模块'app'不可用!您要么拼错了模块名,要么忘记加载它。如果注册模块时,请确保将依赖项指定为第二个论点。
我可以看到,我没有拼错模块的名字在任何地方,我已经包括了必要的模块的依赖关系,我已经结构化的模块在必要的顺序,使没有模块是未定义的彼此(如在房间。Controllers模块在被注入之前就存在,rooms模块在被注入到app模块之前就存在
(function(){
'use strict';
//create the module that is going to contain the controllers for the rooms module
angular.module('rooms.controllers', [])
.controller('RoomCtrl', RoomCtrl);
function RoomCtrl(){
var vm = this;
vm.rooms = [];
};
})();
(function(){
'use strict';
//create the rooms module and inject rooms.controllers module and ngRoute module
angular
.module('rooms', ['rooms.controllers', 'ngRoute']);
});
(function(){
'use strict';
//get the rooms module and config it's routes, because we're getting it we don't need []
angular
.module('rooms')
.config(function($routeProvider){
$routeProvider
.when('/rooms',{
templateUrl:'public/modules/rooms/templates/roomlist.html',
controller: 'RoomCtrl',
controllerAs: 'room'
})
})
})();
(function(){
'use strict';
//bootstrap the whole thing together
angular.module('app', ['rooms']);
})();
此代码块不执行。
(function(){
'use strict';
//create the rooms module and inject rooms.controllers module and ngRoute module
angular.module('rooms', ['rooms.controllers', 'ngRoute']);
})(); // <-- here
相关文章:
- Angular重命名模块后未能实例化模块
- 在Meteor Angular 1.3中使用npm模块
- 如何将Angular 2用于各种网站&使用PHP作为后端的模块
- grunt serve:dist时找不到Angular.js模块,但grunt serve工作正常
- $injector:modulerr将自定义模块注入Angular应用程序
- 如何管理不同的 Angular 模块依赖关系
- 如何检查angular是否已经有模块
- 从函数内部、类内部、模块内部访问 Angular 服务
- 将登录验证模块与现有的Angular JS应用程序集成
- 无法实例化Angular js中的模块错误
- Angular模块仅适用于内联javascript
- 使用Angular JS将常量注入其他模块配置
- 无法在 Angular JS 中加载模块
- 在 Angular js 的不同文件中使用多个模块
- 当作为 CommonJS 模块加载时,Angular 是否全局将自己分配给“window.angular”
- 从 Angular 控制器访问不同模块中的角度服务
- Angular JS生成PDF - 任何创建者 - 制造商模块
- AngularJS - $injector:modulerr 模块错误在 angular.js:36.
- 在 Angular 中动态注入依赖模块
- 无法找到模块'angular'