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> When you are looking to apply for a mortgage the one thing that most people…
Once you've memorized basic blackjack strategy, it's time to delve deeper into the game. Advanced…
Yoga is no longer just a physical practice. Yoga is popular as a lifestyle practice.…
Best Crypto Sign-Up Bonuses in India 2026: Ranked & Compared Every exchange claims to have…
One of the world's busiest travel hubs, New York City relies heavily on coach bus…
Whether large scale or small scale, many businesses want to market their services or products…