Home » AngularJS ng-controller Directive

AngularJS ng-controller Directive

by Online Tutorials Library

AngularJS ng-controller Directive

The AngularJS ng-controller directive adds a controller class to the view (your application). It is the key aspect which specifies the principles behind the Model-View-Controller design pattern.

It facilitates you to write code and make functions and variables, which will be parts of an object, available inside the current HTML element. This object is called scope.

This is supported by all HTML elements.

Syntax:

Parameter explanation:

expression: It specifies the name of the controller.

Let’s take an example to demonstrate ng-controller directive.

See this example:

Test it Now

You may also like