What is a Controller?

devquora
devquora

Posted On: Feb 22, 2018

 

A Controller is a plain javascript function which helps the data flow in an angular application and is responsible for binding the data to the view. A Controller is defined in an application by using ng-controller directive. It is defined in the following fashion: 


var app = angular.module("myApp", []);
app.controller('myCtrl', function($scope) {});

It is usually referenced after the module is referenced. $scope is passed as an argument to the controller which is helps controller point to the view it has to control. A controller is the key aspect which helps angular to develop applications in MVC architectural pattern.

    Related Questions

    Please Login or Register to leave a response.

    Related Questions

    AngularJS Basic Interview Questions

    What is AngularJS?

    AngularJS is a javascript framework which helps in developing web applications in MVC architectural pattern & SPA or..

    AngularJS Basic Interview Questions

    What are angular directives?

    Angular directives are the attributes which are decorated on the html tags or elements of an html page. Directives have ..

    AngularJS Basic Interview Questions

    What are custom directives?

    Angular provides the ability to create our own directives to implement our own custom templates or logic in our web appl..