角度路由器需要模块已加载的组件

时间:2018-06-26 16:39:55

标签: angular routing

我希望路由器路由到不同的组件视图。这些组件通过另一个模块app-module.ts导入到student-module.ts中。但是,当我尝试在app-module.ts中包含的路由器中引用它们时,VSCode指示错误并建议从不导入组件。

file structure
> src/
 > app/
   app.module.ts
   > student/
     > student.module.ts
     > studentcomponent/
       > student.component.ts

这是app.module.ts

的结构
...
import { StudentModule } from './student/student.module';
...
// without importing components named below, VScode indicates error here and suggest that I import them here

const appRoutes: Routes = [
 { path: 'student', component: StudentDashboardComponent },
 { path: 'student/courses', component: StudentCoursesComponent },
 { path: 'student/coursehistory', component: CoursehistoryComponent}
];

0 个答案:

没有答案