AngularJS Controllers

1.What is Angular Js Controllers?

Angular Js Applications are controlled by the controller to control the flow of data in the application.

A controller is a javascript object containing a attributes/properties and functions.

Each controller accepts $scope as a parameter which refers to application/module that controller to control.

The ng-controller directive defines the application controller.


<!DOCTYPE html>
<script src="
<div ng-app="myFirstApp" ng-controller="myController">
First Name: <input type="text" ng-model="fName"><br>
Last Name: <input type="text" ng-model="lName"><br>
<br> Name: {{fName + " " + lName}}
var myFirstApp= angular.module('myFirstApp', []);
myFirstApp.controller('myController', function($scope) { $scope.fName = 'Abc'; $scope.lName = "Learn";