Dependency injection 角度2指令语法
是否有人可以从外部模板(未在组件装饰器内联声明)中澄清此语法(特别是*mycomponent):Dependency injection 角度2指令语法,dependency-injection,angular,Dependency Injection,Angular,是否有人可以从外部模板(未在组件装饰器内联声明)中澄清此语法(特别是*mycomponent): 事实上,*字符是应用结构指令的方式,是以下内容的快捷方式: <template mycomponent> <my-component></my-component> </template> 要应用此指令,您需要使用要使用它的组件的directives属性来定义它 这样的指令将以这种方式执行。参见NgIf one的示例: 具体来说,您可以
事实上,*字符是应用结构指令的方式,是以下内容的快捷方式:
<template mycomponent>
<my-component></my-component>
</template>
要应用此指令,您需要使用要使用它的组件的directives属性来定义它
这样的指令将以这种方式执行。参见NgIf one的示例:
@Component({
selector: 'my-component',
directives: [SubComponent],
template: `
...
`
})
<template mycomponent>
<my-component></my-component>
</template>