用其内容替换组件 - 角度2 [英] replace component with its content - angular 2
问题描述
我正在寻找一种方法来获得仅使用其内容呈现的组件。例如,给定组件:
I am looking for a way to have a component that is rendered only with its content. For example, Given the component:
@Component({selector: 'my-cmp', template: '<div> my-cmp </div>'})
class MyComponent {
}
使用angular2渲染它会将以下内容添加到DOM:
rendering it with angular2 will add the following to the DOM:
<my-cmp>
<div> my-cmp </div>
</my-cmp>
虽然我想找到一种直接渲染方式:
While I want to find a way to render it directly as:
<div> my-cmp </div>
可悲的是,因为角度2相对较新(只是测试版) - 谷歌不是那么有用,不是提到当前的文档是多么缺乏..
Sadly since angular 2 is relatively new (just went beta) - Google is not so helpful, not to mention how lacking the current documentation is..
推荐答案
根据文档 of angular 1.x
According to documentation of angular 1.x
替换指令的元素本身(如果替换为真 -
DEPRECATED)。
Replace the directive's element itself (if replace is true - DEPRECATED).
所以我认为这个功能将不可用角度2
So i think this feature won't be available it angular 2
这篇关于用其内容替换组件 - 角度2的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!