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> Very few brands suffer from a product issue. It's a conversion issue. People enter DMart,…
The onboarding process of the retailer, distributor, or partner may soon become problematic if there…
Many of the states in the United States of America allow the use of medical…
Did you know that every time you browse this website or any other, you leave…
Online casino has gained immense popularity with the rise of online casinos. Platforms like GameZone…
Every business has one or several peak seasons or periods of time during the year…