加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 综合聚焦 > 服务器 > 安全 > 正文

angular – 有没有办法创建组件那些HTML模板替换自定义选择器?

发布时间:2020-12-17 07:35:46 所属栏目:安全 来源:网络整理
导读:我正在努力教自己angular2.我试图构建组件“trigger-resize”,我想渲染为: a class="hidden-xs" href="" em class="fa fa-navicon"/em/a 而不是: trigger-resize a class="hidden-xs" href="" em class="fa fa-navicon"/em /a/trigger-resize (我不希望自
我正在努力教自己angular2.我试图构建组件“trigger-resize”,我想渲染为:
<a class="hidden-xs" href="">
    <em class="fa fa-navicon"></em>
</a>

而不是:

<trigger-resize>

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

(我不希望自定义选择器渲染)

在角度1.我知道它将通过“replace:true”选项实现,但是有可能在angular2中实现它吗?

亲切的问候

一种方法是使用属性
<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>'
})

CamelCase属性现在是angular2中自定义属性的正确语法

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读