Controllers in AngularJS

Applications in AngularJS are controlled by controllers. It controls the data of application. These are the JavaScript Object which holds attributes and functions. It is defined by ng-controller. It uses $scope as a parameter. $scope objects communicates with view and exposes model to the view.

<div ng-app = "" ng-controller = "controller_name">

Watch this TypeScript vs JavaScript Tutorial Video for Beginners:

AngularJS Controllers


<title>AngularJS Controller</title>
<script src = ""></script>
<h2>Example of AngularJS Controllers </h2>
<div ng-app="details" ng-controller="employeecontroller">
Id: <input type="text" ng-model="id"><br><br>
Name: <input type="text" ng-model="name"><br>
Details of Employee: {{id + " " + name}}
var e = angular.module('details', []);
e.controller('employeecontroller', function($scope) {
$ = 20;
$ = "abc";


Recommended Videos

Leave a Reply

Your email address will not be published. Required fields are marked *