How to bind inner html to angular1 elements with ng-bind attribute

2.1k views Asked by At

<div ng-bind="model">
  <div>inner html</div>
</div>

Does anyone know how to display the inner div? Seems the ng-bind directive will always rewrite div element.

Thanks in advance.

1

There are 1 answers

2
Marlon Barcarol On BEST ANSWER

ng-bind will always print what is in the model. You can do the following thing:

<div>
    <div ng-bind="model"></div>
    <div>inner html</div>
</div>

Either you can do something like:

//JS
app.controller("nameController", function($sce) {
   model = $sce.trustAsHtml("<div>inner html</div>");
});

//HTML
<div ng-bind-html="model"></div>