Monday, June 15, 2015

Angular JS - Controllers

  •   In Angular JS Controller is the Javascript constructor function. 
  •   When directive ng-controller is added to the DOM, Angular create a   constructor function to the controller.
  •   And creates variable $scope to the respective controller.
 
  <body ng-app="myApp">
     <div ng-controller="myController"> {{message}} <br />
     <input type="text" ng-model="sqr" ng-init="sqr=5"> Square of      <b>{{sqr}}</b> = {{square(sqr)}}
     </div>
  </body>

 
  <script>
  var myApp = angular.module('myApp',[]);
  myApp.controller('myController', ['$scope', function($scope) {

     //Property to the scope
     $scope.message = 'Hello!';
   
     //Behaviour to the scope
     $scope.square = function(v) {
        return v * v;
     };

  }]);
  </script>

3 comments:

Unknown said...

this is valuable information for learners.thanks
Angularjs Training In Hyderabad

for ict 99 said...

I have read your blog its very attractive and impressive. I like it your blog.

Angularjs Online Training Angularjs Training Angularjs Training Angularjs Training in Chennai Angularjs Training in Chennai Angularjs Course Angularjs Course Angular 2 Training in Chennai

for ict 99 said...

Angular 2 Training in Chennai angular2 Training in Chennai | angular2 Training in Chennai


Angular 2 Training in Chennai AngularJS Training in Chennai AngularJS Training in Chennai Angularjs Training Angularjs Training AngularJS Training in Chennai AngularJS Training in Chennai

AWS Interview Questions and Answers

Sure! Here are the answers to the **AWS Services and Cloud Infrastructure** questions: ### **AWS Services and Cloud Infrastructure (50 Ques...