Kmspico Download | Official KMS Activator Website [New Version 2024] Fast and Easy Converter YouTube to MP3 Online KMSAuto Net Activator Download 2024 Immediate Byte Pro Neoprofit AI Blacksprut without borders. Discover new shopping opportunities here where each link is an entrance to a world ruled by anonymity and freedom.

Use Controller in Angularjs?

Controller in Angularjs

AngularJS Controllers control the data of AngularJS applications. A Controller is the most useful part of an AngularJS application. It performs majority of Javascript functions related and UI related tasks.AngularJS controller is defined with Ng-Controller instructions to control the flow of data in the application. AngularJS Controller is a Javascript Object which includes Attributes and Functions.

The Ng-Controller Directive is used to connect all types of websites with Angularjs Controller. The best thing about a website built using AngularJs is that it is based on Angularjs Controller.

For Example : –

<!DOCTYPE html>
<html>
<head>
<title>Angular JS Controller Example</title>
<script src ="https://ajax.googleapis.com/ajax/libs/angularjs/1.3.14/angular.min.js">
</script>
</head>
<body>
<h2>This is AngularJS Application</h2>
<div ng-app = "mainApp" ng-controller = "studentController">
Enter first name: <input type = "text" ng-model = "student.firstName">
<br><br>
Enter last name: <input type = "text" ng-model = "student.lastName">
<br><br>
You are entering: {{student.fullName()}}
</div>
<script>
var mainApp = angular.module("mainApp", []);
mainApp.controller('studentController', function($scope) {
$scope.student = {
firstName: "Jyoti",
lastName: "Chaurasiya",
fullName: function() {
var studentObject;
studentObject = $scope.student;
return studentObject.firstName + " " + studentObject.lastName;
}
};
});
</script>
</body>
</html>
Angular JS Controller Example

This is AngularJS Application

Enter first name:

Enter last name:

You are entering: {{student.fullName()}}