缩小后我出现注射错误。我找不到这段代码的错误。
的index.html
<!DOCTYPE html>
<html lang="en">
<head>
<meta name="viewport" content="width=device-width, initial-scale=1">
<link href="/stylesheets/style.css" rel="stylesheet">
<link href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet">
<link rel="icon" href="data:;base64,iVBORw0KGgo=">
<!-- Angular Material style sheet -->
<link rel="stylesheet" href="http://ajax.googleapis.com/ajax/libs/angular_material/1.1.0/angular-material.min.css">
</head>
<body ng-app="app" ng-cloak>
<div ng-controller="SideNavController as vm">
<p>
{{vm.name}}
</p>
</div>
<script src="http://ajax.googleapis.com/ajax/libs/angularjs/1.5.8/angular.min.js"></script>
<script src="http://ajax.googleapis.com/ajax/libs/angularjs/1.5.8/angular-animate.min.js"></script>
<script src="http://ajax.googleapis.com/ajax/libs/angularjs/1.5.8/angular-aria.min.js"></script>
<script src="http://ajax.googleapis.com/ajax/libs/angularjs/1.5.8/angular-messages.min.js"></script>
<!-- Angular Material Library -->
<script src="http://ajax.googleapis.com/ajax/libs/angular_material/1.1.0/angular-material.min.js"></script>
<script src="http://ajax.googleapis.com/ajax/libs/angularjs/1.5.8/angular-sanitize.min.js"></script>
<!-- <script src="layout/main-container.controller.js"></script> -->
<!-- My application -->
<script src="/scripts/app.min.js"></script>
</body>
</html>
这是我的连续和缩小后的脚本 /scripts/app.min.js
!function()
{"use strict";function n(){}
angular.module("app").config(n)}(),
function(){angular.module("app",["ngMaterial","ngSanitize","ngAnimate","app.layout"])}()
,function(){"use strict";function n(){console.log("run app")}
angular.module("app").run(n)}(),
function(){"use strict";function n(){var n=this;n.name="SideNavController"}
angular.module("app.layout",[]).controller("SideNavController",n)}();
我收到此错误:
angular.js:2082 Uncaught Error: [$injector:nomod] http://errors.angularjs.org/1.5.8/$injector/nomod?p0=app(…)
angular.js:4640 Uncaught Error: [$injector:modulerr] http://errors.angularjs.org/1.5.8/$injector/modulerr?p0=app&p1=Error%3A%20%…gleapis.com%2Fajax%2Flibs%2Fangularjs%2F1.5.8%2Fangular.min.js%3A189%3A487)(…)
原始sidenav.controller.js
(function(){
'use strict'; // ECMAScript version 5
angular.module('app.layout', [])
.controller('SideNavController', SideNavController);
/* @ngInject */
function SideNavController() {
var vm = this;
vm.name = "SideNavController";
}
})();
app.module.js
(function(){
angular.module('app', [
/* AngularJS modules */
'ngMaterial',
'ngSanitize',
'ngAnimate',
/* app.feature modules */
'app.layout'
/* cross.app modules */
]);
})();
答案 0 :(得分:0)
我必须更改app.min.js中缩小功能的顺序。
!function()
{
angular.module("app",["ngMaterial","ngSanitize","ngAnimate","app.layout"])
}(),
function(){
"use strict";function n(){}
angular.module("app").config(n)
}(),
function()
{
"use strict";
function n(){
console.log("run app")
}
angular.module("app").run(n)
}(),
function()
{
"use strict";
function n(){var n=this;n.name="SideNavController"}
angular.module("app.layout",[]).controller("SideNavController",n)
}();