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 life, finances are inevitable. And more often than not, they can be overwhelming. Having…
The management of a property isn't solely the process of collecting rental. It also involves…
Development and progression are not only essential but often one of the main goals of…
People usually stumble onto the 461 visa when they realise there’s no simple way to…
When you run a brick-and-mortar retail store, you encounter an array of customer personalities. From…
In today’s digital era, people look for convenience, transparency, and genuine rewards from their financial…