有没有方法来创建组件的HTML模板取代定制选择? [英] is there way to create component those HTML template replaces custom selector?

查看:126
本文介绍了有没有方法来创建组件的HTML模板取代定制选择?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图教我angular2。我试图建立组件触发调整大小,这是我想要呈现为:

i'm trying to teach myself angular2. I trying to build component "trigger-resize", which i want to render as :

<a class="hidden-xs" href="">
    <em class="fa fa-navicon"></em>
</a>

和NOT:

<trigger-resize>

   <a class="hidden-xs" href="">
      <em class="fa fa-navicon"></em>
   </a>
</trigger-resize>

(我不想定制选择渲染)

(i dont want custom selector to render)

在角1.我知道这将是取代:真正的能实现吗?选项,但有可能实现它在angular2

In angular 1. i know it would be achieved by "replace:true" option, but is it possible to achieve it in angular2?

亲切的问候

推荐答案

要做到这一点是使用属性的一种方式。

One way to do it is to use an attribute

<a triggerResize class="hidden-xs" href=""></a>

其中有像

@Component({
    selector : 'a[triggerResize]', //select all <a> tags with triggerResize attribute
    template : '<em class="fa fa-navicon"></em>'
})

驼峰属性现在正确的语法在angular2为自定义属性。

CamelCase attributes are the proper syntax now for custom attributes in angular2

这篇关于有没有方法来创建组件的HTML模板取代定制选择?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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