VOOZH about

URL: https://www.geeksforgeeks.org/angular-js/how-to-insert-html-into-view-from-angularjs-controller/

⇱ How to insert HTML into view from AngularJS controller? - GeeksforGeeks


  • Courses
  • Tutorials
  • Interview Prep

How to insert HTML into view from AngularJS controller?

Last Updated : 12 Jul, 2025
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. Syntax:
<element ng-bind-html="expression"></element>
ngSanitize: 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,
Parameters:
  • Expressions: Specifies an expression or the value for the evaluation.
Example 1: Output: 👁 Image
Example 2: Output: 👁 Image
Comment

Explore