0

I'd like to render raw html snippet inside angular's double curly braces, but couldn't find a way to do it. I know there's ng-bind-html directive for binding raw html text, but this only works inside a tag (I mean it replaces the contents of a tag), but I want to insert a html snippet without enclosing it in any tag.

Example:

<div class="row">
    <div>....</div>
    <div>....</div>
    .....
    <div>...</div>

{{</div><div class="row">}}  <- here's what i'd like to insert - close a row and start a next one 

    <div>....</div>
    <div>....</div>
    .....
    <div>...</div>

</div>

So, if you look at the html structure above, I want to insert a closing tag and immediately open a new one. This has to be done dynamically, because all the content is dynamic and I would like to divide it into rows depending on the data model. Any ideas?

Mukesh Ram
  • 6,248
  • 4
  • 19
  • 37
nightwatch
  • 1,276
  • 2
  • 18
  • 27
  • see this link [click here](http://stackoverflow.com/questions/28444803/angularjs-render-html-within-double-curly-brace-notation) it is same as your question – Pratik Bhajankar Feb 04 '16 at 09:44
  • 1
    That is not a good approach to do such things. Better to use specific components for each one. – Jai Feb 04 '16 at 09:44
  • I agree with Jai that it is not a good approach. Maybe you could have to objects and redivide both contents the way you need. If the {{ code }} should not be rendered then first element should have all the items, and if it does split it where you need. – kodvin Feb 04 '16 at 09:47
  • Possible duplicate of [AngularJS ng-include](http://stackoverflow.com/questions/13943471/angularjs-ng-include) – Daniel Mizerski Feb 04 '16 at 09:57

2 Answers2

0

I'm not sure about what you wanna do, and I'm very sure, that it's not the best way or even smart, but you can try this:

{{'</div><div class="row">'}}

JohnnyTheTank
  • 668
  • 5
  • 14
0

Define one variable in your scope:

$scope.rowHtml = "<strong>Your text here</strong>"

Assign it to ng-model of your <DIV>

<div class="row" ng-model="rowHtml ">
Mahesh
  • 1,063
  • 1
  • 12
  • 29