How to get directions between modules in angular2?

I am using angular2 Final for development.

I created 3 modules.

  • Appmodule
  • Projectmodule
  • DesignerModule

Previously, I had only the AppModule into which I imported after the RoutingModule, and it worked fine.

import {NgModule} from '@angular/core';
import { Routes, RouterModule } from '@angular/router';
import {ProjectManagerComponent} from './project-manager/project-manager.component';
import {DesignerComponent} from './designer/designer.component';

const appRoutes: Routes = [
  {path: '',redirectTo: 'project-manager',pathMatch: 'full'},
  { path: 'project-manager', component: ProjectManagerComponent },
  { path: 'designer/:id', component:DesignerComponent }  
];

@NgModule({
  imports:[RouterModule.forRoot(appRoutes)],
  exports:[RouterModule]
})
export class AppRoutingModule { }
export const routingComponents=[ProjectManagerComponent,DesignerComponent]

But recently, I created separate NgModules for ProjectManager and Designer.

I saved ProjectManagerComponent, DesignerComponent inside declarations in my respective modules.

I want to know if these modules can be routed using the same routing configuration or if I need to change something.

My routing no longer works.

any inputs?

+4
source share
1 answer

instead

export const routingComponents=[ProjectManagerComponent,DesignerComponent]

export const routing = RouterModule.forRoot(appRoutes);

app.module.ts ProjectManagerComponent DesignerComponent . , .

app.module.ts

// All the other imports import {routing} from './app.routes;' @NgModule({ imports:[routing, /*Other Modules*/], })

0

Source: https://habr.com/ru/post/1656083/


All Articles