On Github mikem3d / angularmiami
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.18/angular.min.js"></script>
AngularJS is a structural framework for dynamic web apps.
This is a "template". The transformed and rendered DOM is then called the "view".
Data-binding in Angular apps is the automatic synchronization of data between the model and view components.
In Angular, a Controller is a JavaScript constructor function that is used to augment the Angular Scope. When a Controller is attached to the DOM via the ng-controller directive, Angular will instantiate a new Controller object, using the specified Controller's constructor function.
Scope is the glue between application controller and the view. It is an execution context for expressions. Scopes can watch expressions and propagate events.
Scopes provide APIs ($watch) to observe model mutations. and ($apply) to propagate any model changes through the system into the view from outside of the "Angular realm" (controllers, services, Angular event handlers).
when do you need to call $apply()? Very rarely, actually. AngularJS actually calls almost all of your code within an $apply call. Events like ng-click, controller initialization, $http callbacks are all wrapped in $scope.$apply(). So you don’t need to call it yourself, in fact you can’t. Calling $apply inside $apply will throw an error.Each Angular application has exactly one root scope, but may have several child scopes.
In general, a Controller shouldn't try to do too much. It should contain only the business logic needed for a single view. The most common way to keep Controllers slim is by encapsulating work that doesn't belong to controllers into services and then using these services in Controllers via dependency injection.