简体   繁体   English

我可以在Angular 2中使用标签模板吗?

[英]Can i use tags templates in Angular 2?

For example: 例如:

<div class="content">
    <h1>Title</h1>
    {{ include("../tags/inputBox",{name:'abcd',value:1234}); }}
</div>
<div class="content">
    <h1>Title 2</h1>
    {{ include("../tags/inputBox",{name:'efg',value:567}); }}
</div>

Or it is not provided? 还是没有提供?

Templates that you want to be processed by Angular (binding, creating components, directives, ...) have to be provided statically. 您要由Angular处理的模板(绑定,创建组件,指令等)必须静态提供。 There are some ugly workarounds without any guarantee be work in the future. 有一些丑陋的解决方法,不能保证将来可以使用。

The only officially supported way is as far as I know DynamicComponentLoader 据我所知,唯一受官方支持的方式是DynamicComponentLoader

If you are talking about injecting dynamic template with values, parse it, show it and all with ng-include ( #Angular1 ) kinda directive then look at here github issue (fyi #Angular2) , it is clearly stated that 如果您正在谈论使用值注入动态模板,对其进行解析,使用ng-include#Angular1 )kinda指令将其全部显示,然后在此处查看github问题(fyi #Angular2) ,则可以清楚地指出:

ng-include will not be added as it has security issues 由于存在安全问题,因此不会添加ng-include

But you can surely use DynamicComponentLoader . 但是您可以肯定使用DynamicComponentLoader

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM