NG-点击不会NG绑定,HTML工作 [英] ng-click won't work with ng-bind-html

查看:169
本文介绍了NG-点击不会NG绑定,HTML工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有HTML模板是这样的:

I have html template like this:

$scope.template = '<span class="pointer"><i class="icon-refresh pointer" ng-click="refresh()"></i></span>';

我想用 NG-绑定-HTML 这个模板进行绑定,我试图使用它,我也用 NG绑定,HTML的不安全,但不幸的是它绑定在html字符串,​​因为它是一个没有点击的动作。

I want to bind this template using ng-bind-html, I tried to use it and also I used ng-bind-html-unsafe, but unfortunately It bind the html string as it is with no click action.

<span ng-bind-html="template"></span>
<span ng-bind-html-unsafe="template"></span>

我也读到了类似的问题,它说, NG-点击终止后,加载纳克绑定,这样可以有人介绍我如何解决这个问题呢?

I read about similar problem and it said that ng-click is loaded after ng-bind, so can anybody introduce to me how to solve this problem?

推荐答案

您可以尝试NG-包括,把你的模板,以一个静态文件来代替。

You could try ng-include and put your template in to a static file instead.

在范围内的变量把HTML内容的一种违背一些棱角理念的指导方针,我相信。

Putting HTML content in scope variables kind of goes against some angular philosophy guidelines, I believe.

如果你以后更改模板,你会希望它重新绑定本身并再次处理?

If you were to later change the template, would you want it to rebind itself and be processed again?

这篇关于NG-点击不会NG绑定,HTML工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆