Controllers – OnlineWebTutorial.Com

Controllers – AngularJS

Controllers are used to control the flow of data in AngularJS application. ng-controller directive is used to define controller. Controllers are JavaScript objects that contain attributes and functions. Attributes are also called as properties. $scope object is used to invoke the controller. $scope refers to the application which uses the application. We are creating a simple Controller here: <script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.6.1/angular.min.js"></script> <div ng-app="firstApp" ng-controller="firstCtroller"> {{ state + " " + city }} <div>Full Address: {{address}}</div> </div> <script> var app = angular.module("firstApp", []); app.controller("firstCtroller", function($scope) { $scope.state = "Hyderabad"; $scope.city = "Sikandrabad"; $scope.address = $scope.state + " " + $scope.city; }); </script> […]


Facebook
Google+
Twitter
Visit Us
PINTEREST
LinkedIn