Let's say I have usual component MyComponent
. To use it, should I pass it to declarations
array in my main module or directives
array in main component?
// 1)
@NgModule({
declarations: [
AppComponent,
MyComponent
],
imports: [],
providers: [],
bootstrap: [AppComponent]
})
// 2)
@Component({
selector: 'app-root',
directives: [MyComponent]
})
export class AppComponent { }
What if the component is deep into application tree, could I use it anywhere in main module, if passed to declarations
array?
angular@2.0.0-rc.5
答案 0 :(得分:3)
directives
and pipes
in @Component()
and @Directive()
are deprecated. declarations
is the new RC.5/NgModule
s way.