Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Two Angular controllers on the same page

<script src="../angular/angular.min.js"></script>
<script src="two.js"></script>

<div ng-app="DemoApp">
    <div ng-controller="OneController">
        {{name}} <input ng-model="title"> {{title}}
    </div>
    <div ng-controller="TwoController">
        {{name}} <input ng-model="title"> {{title}}
    </div>
</div>
angular.module('DemoApp', [])
    .controller('OneController', ['$scope', function($scope) {
        $scope.name  = 'One';
    }])
    .controller('TwoController', ['$scope', function($scope) {
        $scope.name  = 'Two';
    }]);