To control the flow of data AngularJS mainly relies on controllers. It is defined using ng-controller directive. Controller contain attributes, properties and functions.
<html> <head> <title>AngularJS Controllers</title> <script src="http://ajax.googleapis.com/ajax/libs/angularjs/1.3.14/angular.min.js"></script> </head> <body> <h2>AngularJS Controllers</h2> <div ng-app="ngApp" ng-controller="nameController"> First name: <input type="text" ng-model="name.firstName"><br><br> Last name: <input type="text" ng-model="name.lastName"><br> <br> Full name: {{name.fullName()}} </div> <script> var ngApp = angular.module("ngApp", []); ngApp.controller('nameController', function($scope) { $scope.name = { firstName: "Mark", lastName: "Taylor", fullName: function() { var nameObject; nameObject = $scope.name; return nameObject.firstName + " " + nameObject.lastName; } }; }); </script> </body> </html>
In a world where digital presence is paramount, the question isn't whether you should do…
Over the years, people have experimented with various methods to maintain healthy and beautiful hair.…
Your brand more than developing an attractive and creative logo and infectious motto. It's the…
Introduction Are you someone who has suffered from a personal injury and want to file…
Operating from home has emerged as one of the most popular ways of doing jobs…
If the consequences of our society’s ever-growing debt are what worries you, then it is…