VOOZH about

URL: https://www.geeksforgeeks.org/angular-js/angularjs-ng-controller-directive/

⇱ AngularJS ng-controller Directive - GeeksforGeeks


  • Courses
  • Tutorials
  • Interview Prep

AngularJS ng-controller Directive

Last Updated : 3 Aug, 2022

The ng-controller Directive in AngularJS is used to add a controller to the application. It can be used to add methods, functions, and variables that can be called on some event like click, etc to perform certain actions. 

Syntax:

<element ng-controller="expression"> 
 Contents... 
</element>

Parameter value:

  • expression: It refers to the name of the controller.

Example 1: This example uses the ng-controller Directive to display the input elements. 

Output: 

👁 ngcontroller

Example 2: This example uses the ng-controller Directive to display content after clicking the button. 

Output:

👁 Image
 
Comment

Explore