How to insert HTML into view from AngularJS controller?
The ng-bind-html directive is a secure way of binding content to an HTML element. So in order to insert HTML into view, we use the respective directive.
While using AngularJS, write HTML in our corresponding application, we should check the HTML for dangerous or error prone code. By including the “angular-sanitize.js” module in the application we can do so by running the HTML code through the ngSanitize function.
It constitutes of 2 steps:
- Include the angular-sanitize.min.js resource,
- In a js file (controller or usually app.js), we must include ngSanitize,
angular.module('myApp', ['myApp.filters', 'myApp.services',
- Expressions: Specifies an expression or the value for the evaluation.