我创建了https://jsfiddle.net/5s126md5/3/
每个控制器都在不同的文件中。
为什么我这样做:[$injector:nomod] Module 'myApp' is not available!
实际上我有多个文件和不同的控制器
angular.module('myApp.controllers', []);
angular.module('myApp', [
'myApp.controllers'
]);
angular.module('myApp.controllers')
.controller('myController', function ($scope) {
$scope.greeting = 'Hola!';
});
angular.module('myApp.controllers')
.controller('AnotherController', function ($scope) {
$scope.greeting = 'Hola! AnotherController';
});
这是HTML:
<body ng-app="myApp">
<div ng-controller="myController">
{{greeting}}
</div>
<div ng-controller="AnotherController">
{{greeting}}
</div>
</body>