Directives in angularjs?

Angularjs consist of many directives. Among them this 3 are main directives.

  1. Ng-app
  2. Ng-model
  3. Ng-click
  4. Ng-App:

The ng-app directive initializes an AngularJS application

  • Ng-model:

The ng-model directive binds the value of HTML controls (input, select, textarea) to application data.

  • Ng-click:

The click directive called the function and execute the code inside the function.

Ex:

<!DOCTYPE html>

<html>

<script src=”https://ajax.googleapis.com/ajax/libs/angularjs/1.6.9/angular.min.js”></script>

<body>

<div ng-app=”” ng-init=”firstName=’John'”>

<p>Input something in the input box:</p>

<p>Name: <input type=”text” ng-model=”firstName”></p>

<p>You wrote: {{ firstName }}</p>

</div>

</body>

</html>

OP: