Articles

AngularJS Controller

by Sumeet Arora CTO,Evon Technologies

AngularJS applications are controlled by controllers. A controller is a JavaScript Object, which is created by a standard JavaScript object called constructor. In below example lastName and firstName are two properties of controller object demonstrated below.

  1. <div ng-app="myApp" ng-controller="myCtrl">
  2. First Name: <input type="text" ng-model="firstName"><br>
  3. Last Name: <input type="text" ng-model="lastName"><br>
  4. <br>
  5. Full Name: {{firstName + " " + lastName}}
  6. div>
  7. <script>
  8. var app = angular.module('myApp', []);
  9. app.controller('myCtrl', function($scope) {
  10.     $scope.firstName = "Raj";
  11.     $scope.lastName = "shekhar";
  12. });
  13. script>

Reference

http://www.w3schools.com/angular/angular_controllers.asp

To read such more blogs on AngularJS please visit our AngularJS Blogs Section.


Sponsor Ads


About Sumeet Arora Advanced   CTO,Evon Technologies

83 connections, 0 recommendations, 219 honor points.
Joined APSense since, March 31st, 2015, From Dehradun, India.

Created on Dec 31st 1969 18:00. Viewed 0 times.

Comments

No comment, be the first to comment.
Please sign in before you comment.