在templatURL动态模板angular2 [英] Dynamic template in templatURL in angular2

查看:321
本文介绍了在templatURL动态模板angular2的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直用NG-包括1角,每当我不得不动态包括tamplate在页面中。

I have been using ng-include in angular 1 whenever I had to include a tamplate dynamically in the page.

现在如何达致这在角2。我试图寻找并发现这些:

Now how to acheive this in angular 2. I have tried searching and found these :

https://groups.google.com/forum/#​​!topic/角/ ROkKDHboWoA

https://github.com/angular/angular/issues/2753

有人可以解释如何在angular2为纽带,做到这一点说,NG-包括不包括由于一些安全方面的原因。

can someone explain how to do this in angular2 as the link says ng-include is not included due some security reasons.

或至少如何使用templateUrl财产veriable从而使veriable值可以在服务器端进行处理,以服务模板...

Or atleast how to use a veriable in templateUrl property so that the veriable value can be handled on server side to serve the template...

推荐答案

其实角2还没有在当前构建特色这一点。另外,作为每添加链接,我不觉得这个功能将包括在内。

Actually angular 2 has not featured this in the current build. Also as per the links added, I don't think this feature will be included.

可以使用一段JavaScript代码使用Ajax调用动态添加模板。

A piece of javascript to dynamically add template using ajax call may be used.

或可能在未来的动态模板加载器库将可以使用了。

Or possibly in future a dynamic template loader library will be available for use.

这篇关于在templatURL动态模板angular2的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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