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>
<title>Angular JS Controller Example</title>
<script src ="">
<h2>This is AngularJS Application</h2>
<div ng-app = "mainApp" ng-controller = "studentController">
Enter first name: <input type = "text" ng-model = "student.firstName">
Enter last name: <input type = "text" ng-model = "student.lastName">
You are entering: {{student.fullName()}}
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;
Angular JS Controller Example

This is AngularJS Application

Enter first name:

Enter last name:

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