未捕获错误:[$injector:modulerr]实例化模块失败,原因是:
Uncaught Error: [$injector:modulerr] Failed to instantiate module due to:
首先我得说我已经找遍了所有与我的问题相关的问题,但是我没有找到任何解决我的问题的方法。
Uncaught Error: [$injector:modulerr] Failed to instantiate module Arrows due to:
Error: [$injector:nomod] Module 'Arrows' is not available! You either misspelled the
module name or forgot to load it. If registering a module ensure that you specify ...
<omitted>...2)
我的index . html :
<html ng-app='Arrows'>
<head>
<title>Arrows</title>
<script data-main="app" src="modules/require.js"></script>
<link rel="stylesheet" type="text/css" href="styles/style.css">
<script src="modules/angular-1.2.21/angular.js"></script>
<script src="modules/angular-1.2.21/angular-route.js"></script>
</head>
<body ng-controller='menuController'>
<div ng-view>
{{ message }}
</div>
</body>
</html>
我app.js :
define([
'./controller/menu',
'./controller/game'
], function(
menu,
game
) {
var Arrows = angular.module('Arrows', ['ngRoute']);
Arrows.config(function($routeProvider) {
$routeProvider
.when('/', {
templateUrl : 'pages/menu.html',
controller : 'menuController'
})
.when('/game', {
templateUrl : 'pages/game.html',
controller : 'gameController'
})
.otherwise( {
redirectTo: '/',
controller: 'menuController'
});
});
Arrows.controller('gameController', function($scope) {
$scope.message = 'hello! Its working!';
});
Arrows.controller('menuController', function($scope) {
$scope.message = 'hello! Its working!';
});
});
不知道在那里做什么。我的意思是,我加载了angular-route.js,关于这个错误的大多数问题的答案是什么?我确保在html-tag内写ng-app='Arrows'
当你使用require.js时,你必须以一种特殊的方式引导你的AngularJS应用程序。阅读这篇文章- https://www.startersquad.com/blog/angularjs-requirejs/-并尝试将其中描述的内容结合到您的具体案例中。
最后你会使用像
这样的东西define([
'require',
'angular'
], function (require, ng) {
'use strict';
require(['domReady!'], function (document) {
ng.bootstrap(document, ['Arrows']);
});
});
相关文章:
- 意外的令牌模块生成失败:SyntaxError
- 使用Q节点模块时,Bluemix node.js应用程序部署失败
- webpack配置警告和错误:;模块解析失败”;
- 添加角光栅时模块实例化失败
- 导入模块失败's css文件
- 模块构建失败:引用错误:[BABEL] 未知选项:base.stage
- webpack 解析模块 'blueimp-load-image' 失败
- Webpack 模块构建失败意外令牌(rails react build)
- 命令失败: gm 识别: 无法打开文件 (2) [没有这样的文件或目录].通用模块和 ES6 承诺的问题
- AngularJS 依赖注入在模块中失败
- AngularJS加载模块失败
- 角度模块加载失败
- Gulp.js安装失败,找不到模块'fetch.js'
- Angular--实例化模块失败
- 为什么当子模块构建失败时,NPM会成功
- 实例化模块失败错误:[$injector:unpr]
- 实例化app模块失败.处理步骤为什么
- 未捕获错误:[$injector:modulerr]实例化模块失败,原因是:
- Grunt失败,提示“无法找到模块”.对于本地模块
- Angularjs、Typescript、Uglify实例化myApp模块失败未知提供商:a