我意识到有时候我会看到angular2代码为:
@Component({
selector: '[ui-components]'
selector: '[ui-components]
是什么意思?
答案 0 :(得分:6)
这意味着您将组件作为属性组件而不是元素组件。当您在html中使用该组件时,您可以编写
<div ui-components></div>
如果您使用
@Component({
selector: 'ui-components' // without the brackets
你必须在你的html
中使用这种表示法<ui-components></ui-components>
Here是Angular2文档中的一些读物。