角$编译模块外 [英] Angular $compile outside modules

查看:142
本文介绍了角$编译模块外的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个问题与AngularJS编译服务。我工作了的角,但我不能编译我的模板,(我可尝试用一个控制器,但是我不知道为什么它不工作)。

I have an issue with AngularJS compile service. I am working out of angular but I can not compile my template, (I either try with a controller but I do not know why it does not work).

由于具体发展我不能使用的指令,也不控制器。

Due to specific development I can not use directives nor controllers.

下面是我的问题的Plunker: http://plnkr.co/edit / u9nfopTiikxjXmwzOgqh?p = preVIEW

Here is a Plunker of my issue: http://plnkr.co/edit/u9nfopTiikxjXmwzOgqh?p=preview

PS:这是一个简单的例子,但我真的需要编译服务($插值没有脚我的需要)

PS: This is a simple example, but I really need the compile service ($interpolate does not feet my needs)

推荐答案

它的工作原理!只需拨打范围。$适用()。顺便说一句。如果你在调用 result.html()要附加 HTML 的副本未绑定任何更多的范围。如果你只是追加结果时,奇迹发生了......看的 PLNKR

It works! Just call scope.$apply(). Btw. if you be calling result.html() you are appending the copy of html that is not bound any more to the scope. If you just append result, the magic happens... Look at the PLNKR.

这篇关于角$编译模块外的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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