Reputation: 545
Please help me to understand where's the problem.
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>
And here's 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() {
}
})();
And the error: angular.min.js:6 Uncaught Error: [$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)(…)
Thanks a lot
Upvotes: 0
Views: 735
Reputation: 222522
Define those two controllers in your script.js file.
Check the demo
(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>
Upvotes: 0