Explain ng-bind and ng-bind-html directives

ng-bind: It is a directive which replaces the content of the HTML element with the value of the assigned variable or expression.

The content of the HTML element will change by changing the value of the variable or expression.

It is like ({{expression}}) and the syntax for this is,

<ANY ELEMENT ng-bind=”expression”> </ANY ELEMENT>

ng-bind-html: It is a directive which binds the content to the HTML element(view) in a secure way. $sanitize service is used to sanitize the content to bind into an HTML element. To do this ‘angular-sanitize.js’ must be included in our application.

Syntax to write this,

<ANY ELEMENT ng-bind-html=” expression “> </ANY ELEMENT>

Top 50+ Angular Interview Questions with Answers

Angular is one of the most current web development frameworks around the world.  In almost every interview, you will have… Read More

4 years ago