Angular is based on Model–View–Controller design pattern.
MVC components in angular: (from AngularJS site)
- Model — Models are the properties of a scope; scopes are attached to the DOM where scope properties are accessed through bindings.
- View — The template (HTML with data bindings) that is rendered into the View.
- Controller — The
ngControllerdirective specifies a Controller class; the class contains business logic behind the application to decorate the scope with functions and values.
$scope is the “glue” (ViewModel) between a controller and a view(From Dan Wahlin).
Now we can use the same example using Controller.