ng -app.controller instead of function MyCtrl
by mckennatim
HTML
<!DOCTYPE html>
<body ng-app='app'>
<div ng-controller="MyCtrl as ctrl">
<h4>ng -app.controller instead of function MyCtrl </h4>
<button ng-click="ctrl.doit()">hit me</button>
{{ctrl.result}}
</div>
<script>
var app = angular.module('app', []);
app.controller('MyCtrl', function(){
this.result="dog";
this.doit = function(){
this.result="cat";
}
});
</script>
</body>