[英]Angularjs: render raw html inside double curly braces - possible?
I'd like to render raw html snippet inside angular's double curly braces, but couldn't find a way to do it. 我想在angular的双花括号内渲染原始html代码段,但找不到方法。 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. 我知道有
ng-bind-html
指令用于绑定原始html文本,但这仅在标记内有效(我是说它替换了标记的内容),但是我想插入html代码段而不将其包含在任何标记中。
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. 因此,如果您看一下上面的html结构,我想插入一个结束标记并立即打开一个新标记。 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?
有任何想法吗?
我不确定您要做什么,但我很确定这不是最好的方法,甚至不是聪明的方法,但是您可以尝试以下方法:
{{'</div><div class="row">'}}
Define one variable in your scope: 在您的范围内定义一个变量:
$scope.rowHtml = "<strong>Your text here</strong>"
Assign it to ng-model
of your <DIV>
将其分配给
<DIV>
ng-model
<div class="row" ng-model="rowHtml ">
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.