Rajesh Kumar
Rajesh Kumar

Reputation: 247

Angularjs bind HTML tags inside a HTML tag

Consider the following code which is in my controller file,

$scope.update = "<div class='search'><input type="search" name="search" /></div>";

I want to bind this $scope.update in view inside another div tag. Is it possible to do it in angular.js?

Upvotes: 3

Views: 2827

Answers (1)

Nikhil Aggarwal
Nikhil Aggarwal

Reputation: 28445

Basically, you need to use angular-sanatize library.

Add angular-sanatize.js in your html and in your module give a dependency of "ngSanitize"

And let us say rather than

<div>{{update}}</div>

use

<div ng-bind-html="update"></div>

For more details, please refer to "https://github.com/angular/bower-angular-sanitize"

Upvotes: 4

Related Questions