Questions tagged [ng-bind-html]

ngBindHtml creates a binding that will innerHTML the result of evaluating the expression into the current element in a secure way.

ngBindHtml creates a binding that will innerHTML the result of evaluating the expression into the current element in a secure way. By default, the innerHTML-ed content will be sanitized using the $sanitize service. To utilize this functionality, ensure that $sanitize is available, for example, by including ngSanitize in your module's dependencies (not in core Angular). In order to use ngSanitize in your module's dependencies, you need to include "angular-sanitize.js" in your application.

You may also bypass sanitization for values you know are safe. To do so, bind to an explicitly trusted value via $sce.trustAsHtml. See the example under Strict Contextual Escaping (SCE).

Note: If a $sanitize service is unavailable and the bound value isn't explicitly trusted, you will have an exception (instead of an exploit.)

Usage
as attribute:

<ANY
  ng-bind-html="">
...
</ANY>

Example

<div ng-controller="ExampleController">
 <p ng-bind-html="myHTML"></p>
</div>

Resources

242 questions
0
votes
2 answers

AngularJS ng-bind-html 2way data binding

I have an AngularJS app where I got some data from a webservice and parse some HTML to the template with ng-bind-html ... but when I try to bind data inside the ng-bind-html - nothing happens .. anyone? I have a little example here,.. not the right…
pkdkk
  • 3,905
  • 8
  • 44
  • 69
0
votes
3 answers

Angular directive for customized html tag in table

I got a solution to use AngularJS directive to let html understand my tag bold as the html tag b. So {{testWorks}} will style the text as bold when I have textWorks in the scope. However, it doesn't work when I have {{testText}} where…
Qinjin
  • 401
  • 4
  • 12
0
votes
1 answer

How do I display html coming from a json list in AngularJS?

having a json set of information like [ { "title":"Title 1", "description":"

Some HTML

" }, { "title":"Title 2", "description":"

Some HTML

More HTML

" } ] how do I show the html in my template.…
orbitory
  • 1,090
  • 5
  • 16
  • 40
0
votes
1 answer

how to parse custom html element using ng-bind-html in angularjs

I need to parse a string using ng-bind-html. This string contains some custom html tags in it. Which while parsing using ng-bind-html gives me an error for $sanitize:badparse. Please see the fiddle for error: http://jsfiddle.net/8zS4h/2/ While…
Mayank
  • 112
  • 8
0
votes
1 answer

Using ng-bind-html to assign a form?

I want to click a button to replace a variable with a form. How do I do this? JavaScript var MainCtrl = angular.module('mainCtrl', []); MainCtrl.controller('MainCtrl', function ($scope) { $scope.bar = 'Foo'; $scope.foo = function(){ …
A T
  • 13,008
  • 21
  • 97
  • 158
0
votes
1 answer

Outputting HTML with AngularJS ng-repeat not rendering BOLD fonts

I am trying to output some HTML which is working fine, for the most part but some of the styling is being stripped out. From the images below you can see that the /ul/ is working fine and rendering the /li/ items fine in ng-repeat but the BOLD font…
Brad Martin
  • 5,637
  • 4
  • 28
  • 44
0
votes
1 answer

Why does the ng-bind-html directive of AngularJS changes the overflow behavior of a div?

I am building a console like application using AngularJS. One of my requirements is that the div containing the console is scrolled down automatically. I achieved that using a directive that is monitoring the content and adjusting the scrollTop…
Spontifixus
  • 6,570
  • 9
  • 45
  • 63
0
votes
2 answers

angularjs directive template with ng-bind-html in it, that uses scope of directive

i have a directive, whose template is just
. But the myhtml uses the scope of the directive. I can´t get this work. Example: fiddle
user3306403
  • 33
  • 2
  • 4
0
votes
1 answer

using directive in ng-bind-html

Im trying to call a directive to change view based on my tab click. My directive: Proj.directive('tab1', function() { return { restrict:'E', templateUrl:'partials/overviewPage.html' }; }); and my controller: $scope.selectTab…
user674905
  • 19
  • 1
0
votes
2 answers

How I can get a click event

Hello I have bind some HTML elements. Take a look at below code
In controller code is $scope.myHTML="
" $scope.myFunc= function(){ alert("TEST"); } here my html is correctly…
Shardul Pendse
  • 304
  • 1
  • 4
  • 17
0
votes
1 answer

AngularJS html form binding?

I need to use form tags in ng-bind-html? The ng-bind-html is not binding form tags(form, input). Please provide solution to bind form tags.
Saidh
  • 1,131
  • 1
  • 12
  • 21
0
votes
2 answers

AngularJS 1.2's ngBindHtml doesn't process /r & /n

I have a string that looks like this (lots of whitespace, this is just how it comes out on my server): var care_description = "MATERIAL\r\n \r\n 56% Acrylic, 24% Rayon, 20% Polyester\r\n \r\n CARE\r\n \r\n Machine Wash, Gentle Or…
JVG
  • 20,198
  • 47
  • 132
  • 210
-1
votes
2 answers

Angular JS Inner Html for Ionic Framework

I am developing my application with angularjs and ionic,

I would like to change this to angularjs like innerHTML,