请帮助我了解问题出在哪里。
HTML:
<!doctype html>
<html ng-app='ShoppingListCheckOff'>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="styles/bootstrap.min.css">
<script src="angular.min.js"></script>
<script src="app.js"></script>
</head>
<body>
<div class="col-md-6" ng-controller='ToBuyController' >
</div>
<div class="col-md-6" ng-controller='AlreadyBoughtController' >
</div>
</body>
</html>
这是app.js
(function () {
'use strict';
angular.module('ShoppingListCheckOff', [])
.controller('ToBuyController', MyToBuyController);
.controller('AlreadyBoughtController', MyAlreadyBoughtController);
.service('ShoppingListCheckOffService', ShoppingListCheckOffService);
MyToBuyController.$inject = ['ShoppingListCheckOffService'];
function MyToBuyController($scope, $filter, $injector) {
}
}
/////////////
MyAlreadyBoughtController.$inject = ['ShoppingListCheckOffService'];
}
function ShoppingListCheckOffService() {
}
})();
和错误:angular.min.js:6未捕获的错误:[$ injector:modulerr] http://errors.angularjs.org/1.5.7/ $ injector / modulerr?p0 = ShoppingListCheckOf…%20%20at%20Bc% 20(http%3A%2F%2Flocalhost%3A3000%2Fangular.min.js%3A21%3A163)(…)
非常感谢
在script.js文件中定义这两个控制器。
检查演示
(function () {
'use strict';
var app= angular.module('ShoppingListCheckOff', [])
app.controller("ToBuyController", function($scope) {
$scope.msg ="ToBuyController";
});
app.controller("AlreadyBoughtController", function($scope) {
$scope.msg ="AlreadyBoughtController";
});
})();
<!DOCTYPE html>
<html>
<head>
<script data-require="[email protected]" data-semver="1.4.7" src="https://code.angularjs.org/1.4.7/angular.js"></script>
</head>
<body ng-app="ShoppingListCheckOff">
<div class="col-md-6" ng-controller='ToBuyController' >
{{msg}}
</div>
<div class="col-md-6" ng-controller='AlreadyBoughtController' >
{{msg}}
</div>
</body>
</html>
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句