angular js11.Explain ng-bind directive.
ng-bind directive binds the AngularJS Application data to HTML tags. ng-bind updates the model created by ng-model directive to be displayed in the html tag whenever user input something in the control or updates the html control’s data when model data is updated by controller.

12.Explain ng-controller directive.
ng-controller directive tells AngularJS what controller to use with this view. AngularJS application mainly relies on controllers to control the flow of data in the application. A controller is a JavaScript object containing attributes/properties and functions. Each controller accepts $scope as a parameter which refers to the application/module that controller is to control.

13.How AngularJS integrates with HTML?
AngularJS being a pure javaScript based library integrates easily with HTML.

Step 1 − Include angularjs javascript libray in the html page

<head>
<script src = “http://ajax.googleapis.com/ajax/libs/angularjs/1.3.14/angular.min.js”></script>
</head>
Step 2 − Point to AngularJS app

Next we tell what part of the HTML contains the AngularJS app. This done by adding the ng-app attribute to the root HTML element of the AngularJS app. You can either add it to html element or body element as shown below:

<body ng-app = “myapp”>
</body>

14.Explain ng-init directive.
ng-init directive initializes an AngularJS Application data. It is used to put values to the variables to be used in the application.

15.Explain ng-repeat directive.
ng-repeat directive repeats html elements for each item in a collection.

16.What are AngularJS expressions?
Expressions are used to bind application data to html. Expressions are written inside double braces like {{ expression}}. Expressions behave in same way as ng-bind directives. AngularJS application expressions are pure JavaScript expressions and outputs the data where they are used.

17.Explain uppercase filter.
Uppercase filter converts a text to upper case text.

In below example, we’ve added uppercase filter to an expression using pipe character. Here we’ve added uppercase filter to print student name in all capital letters.

Enter first name:<input type = “text” ng-model = “student.firstName”>
Enter last name: <input type = “text” ng-model = “student.lastName”>
Name in Upper Case: {{student.fullName() | uppercase}}

18.Explain lowercase filter.
Lowercase filter converts a text to lower case text.

In below example, we’ve added lowercase filter to an expression using pipe character. Here we’ve added lowercase filter to print student name in all lowercase letters.

Enter first name:<input type = “text” ng-model = “student.firstName”>
Enter last name: <input type = “text” ng-model = “student.lastName”>
Name in Upper Case: {{student.fullName() | lowercase}}

20.Explain currency filter.
Currency filter formats text in a currency format.

In below example, we’ve added currency filter to an expression returning number using pipe character. Here we’ve added currency filter to print fees using currency format.

Enter fees: <input type = “text” ng-model = “student.fees”>
fees: {{student.fees | currency}}
Explain filter filter.
filter filter is used to filter the array to a subset of it based on provided criteria.

In below example, to display only required subjects, we’ve used subjectName as filter.

Enter subject: <input type = “text” ng-model = “subjectName”>
Subject:
<ul>
<li ng-repeat = “subject in student.subjects | filter: subjectName”>
{{ subject.name + ‘, marks:’ + subject.marks }}
</li>
</ul>

You may also like

Leave a Comment