Search This Blog


Angular JS Tutorial3: ng-controller,filter

The ngController directive attaches a controller class to the view. This is a key aspect of how angular supports the principles behind the Model-View-Controller design pattern.

MVC components in angular:

•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 ngController directive specifies a Controller class; the class contains business logic behind the application to decorate the scope with functions and values.

Filter selects a subset of items from array and returns it as a new array.

Example :

<!DOCTYPE html>
<html lang="en" ng-app="myapp">
 <script src=""></script>

 <div ng-controller="mycontroller">
  <button ng-click=changelang()>Change Language to Bengali</button>

 <script type="text/javascript">
  var application=angular.module('myapp',[]);//[] : use for referring other module


No comments: