【发布时间】:2019-02-28 10:38:21
【问题描述】:
我会用一个例子来问这个问题。我们有这个模块:
import { NgModule } from '@angular/core';
...
import { TodoComponent } from './todo.component';
...
@NgModule({
imports: [CommonModule, ReactiveFormsModule],
exports: [TodosComponent, TodosFiltersComponent],
declarations: [TodoComponent, TodosComponent, TodosFiltersComponent, TodosPageComponent]
})
export class TodosModule {}
我假设TodoComponent 和TodoPageComponent 只能在declarations 数组中列出的其他声明的组件中使用,并且这些是它们唯一可以使用的组件,因为它们没有被导出?只要确保我正确理解了 Angular 组件范围......
【问题讨论】:
-
是的,一个模块的组件只有在没有导出的情况下才能被同一个模块的组件使用
标签: angular typescript scope angular-components