【发布时间】:2016-05-12 20:09:42
【问题描述】:
我有和 angularjs 应用程序。我想将所有 JS 文件连接到一个文件。我目前正在尝试使用 Grunt.js 设置一个自动构建过程来连接 JavaScript 文件。
但是我的应用程序在连接之前运行没有任何错误。但是在连接文件后我的应用程序抛出 错误:$injector:modulerr 模块错误。
下面是我缩小后的代码
angular.module('myApp', []);
var app = angular
.module('myApp', [
'ngRoute'
]);
app.config(function ($routeProvider) {
'use strict';
$routeProvider
.when('/', {
templateUrl: 'views/main.html',
controller: 'mainCntrl'
})
.when('/about', {
templateUrl: 'views/about.html',
controller: 'aboutCntrl',
controllerAs: 'about'
})
.otherwise({
redirectTo: '/'
});
});
app.controller('mainCntrl',['$scope', function ($scope) {
'use strict';
this.awesomeThings = [
'HTML5 Boilerplate',
'AngularJS',
'Karma'
];
}]);
app.controller('aboutCntrl',['$scope', function ($scope) {
'use strict';
this.awesomeThings = [
'HTML5 Boilerplate',
'AngularJS',
'Karma'
];
}]);
任何帮助表示赞赏。谢谢:)
【问题讨论】:
标签: javascript angularjs dependency-injection angularjs-controller