Angular2组件选择器:类似'[ui-components]'

时间:2016-12-14 09:45:22

标签: angular

我意识到有时候我会看到angular2代码为:

@Component({
  selector: '[ui-components]'

selector: '[ui-components]是什么意思?

1 个答案:

答案 0 :(得分:6)

这意味着您将组件作为属性组件而不是元素组件。当您在html中使用该组件时,您可以编写

<div ui-components></div>

如果您使用

@Component({
  selector: 'ui-components' // without the brackets

你必须在你的html

中使用这种表示法
<ui-components></ui-components>

Here是Angular2文档中的一些读物。