The other directive that I am using in this demo is the ng-controller directive, which attaches a controller class to the element. This is a key feature of the MVC design of angular, which will become clearer in additional future posts.
For my basic controller example I am just going to to have a single static value assigned to $scope.mess in a controller called basic-control.
But First the html.
The value that I set in $scope.mess will be set to what is placed in
The javaScipt will look like this:
Because this is very simple example It should be easy to understand the basic idea of a controller. You have a model defined with angular.module which has a name ‘app’. I used the ng-app directive to tell angular to bootstrap the div element with the ‘app’ module. I also tell angular I want to use the ‘basic-control’ controller with the element as well. The controller then sets what I place in to the value defined in $scope.mess within the controller.
I guess even the basic idea of this is a little involved, but not to bad right?