The problem is that you are creating the myApp.controllers
module twice and one is overwriting the other. Assuming that you are manually bootstrapping angular after loading the controller, what you should be doing is to create the module first, then load that module to create controller:
app.js
define(['angular'], function(){
'use strict';
return angular.module('myApp.controllers', []);
});
Index: controller.js
define(['app'], function(app){
'use strict';
return app.controller('indexCtrl', ['$scope' , function ($scope){
alert("index ok");
}]);
});
Test: controller.js
define(['app'], function(app){
'use strict';
return app.controller('testCtrl', ['$scope' , function ($scope){
alert("test ok");
}])
});
I created angularAMD
to facilitate use of RequreJS and AngularJS that might be of interest to you: