1.What are directives?

Directives are markers on a DOM element which attach a special behavior to it.

 

Angular JS directives are extended with prefix ng-

ng-app
ng-init
ng-model

 

2.What is data binding?

Data binding means combining data.

<!DOCTYPE html>
<html>
<script src="http://ajax.googleapis.com/
ajax/libs/angularjs/1.4.8/angular.min.js"></script>
<body>
<div ng-app="myFirstModule " ng-controller="MyController">
{{ firstName + " " + lastName }}
</div>
<script>
var FirstModule = angular.module("myFirstModule ", []);
FirstModule .controller("MyController", function($scope) { $scope.firstName = "ABC"; $scope.lastName = "Learn";
});
</script>
</body>
</html>

 

3. What is ng-app Directive?

The ng-app directive is initialized an angular Js application.

<!DOCTYPE html>
<html>
<script src="http://ajax.googleapis.com/
ajax/libs/angularjs/1.4.8/angular.min.js"></script>
<body>
<div ng-app="myFirstModule " ng-controller="MyController">
{{ firstName + " " + lastName }}
</div>
<script>
var FirstModule = angular.module("myFirstModule ", []);
FirstModule .controller("MyController", function($scope) { $scope.firstName = "Ebc"; $scope.lastName = "Learn";
});
</script>
</body>
</html>

 

4.What is ng-inti directive?

The ng-init directive defines initial values for application data.

<!DOCTYPE html>
<html>
<script src="http://ajax.googleapis.com/
ajax/libs/angularjs/1.4.8/angular.min.js"></script>
<body>
<div ng-app="" ng-init="firstName='Sairam'">
<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>