angular js .controller code example
Example 1: angularjs - controllerAs
<div ng-controller="MainController as MC">
…
</div>
Example 2: angularjs - controllerAs
angular.module('myApp', [])
.config(function ($stateProvider) {
$stateProvider
.state('main', {
url: '/',
controller: 'MainController as MC',
templateUrl: '/path/to/template.html'
})
}).
controller('MainController', function () { … });