angular.module()

by Richard Hunter

HTML

<script src="https://cdnjs.cloudflare.com/ajax/libs/angular.js/1.4.1/angular.min.js"></script>
<h1>angular.module()</h1>
<div ng-controller="fooctrl">
    
    <h2>{{ foo }}</h2>
    <div ng-controller="barctrl">
        <h3>{{ bar }} </h3>
    </div>
</div>

JavaScript

angular.module('myapp', []);

//  retrieve module here. This could obviously be in a different file.
angular.module('myapp')
.controller('fooctrl', ['$scope', function($scope) {
    $scope.foo = 'this is foo';
}]);

angular.module('myapp')
.controller('barctrl', ['$scope', function($scope){
    $scope.bar = 'this is bar';
}]);

angular.bootstrap(document, ['myapp']);