Angular: get module by name
How to get module by name?
HTML
<script src="http://code.angularjs.org/angular-1.0.0rc9.js"></script>
<html ng-app='MyApp'>
<body>
<div ng-controller="Ctrl1">
{{name}}
</div>
<div ng-controller="Ctrl2">
{{name}}
</div>
</body>
</html>
JavaScript
var app = angular.module('MyApp',[]);
app.controller('Ctrl1', ['$scope',function($scope) {
$scope.name = '111';
}]);
// I want to add something to the module `MyApp` in another file
// but following line doesn't work
app = angular.module('MyApp',[]);
app.controller('Ctrl2', ['$scope',function($scope) {
$scope.name = '222';
}]);
document.write(' <div ng-controller="Ctrl1">\
{{name}}\
</div>\
<div ng-controller="Ctrl2">\
{{name}}\
</div>')