简体   繁体   中英

How to navigate one app component to another app component in angular4?

My requirement is:- If there are two apps. app1 and app2. app1 some components and similarly app2. So how to redirect on click app1 component click to app2 component.

Please tell me.

Assuming your routing module be like..

imports goes here ....;

const routes: Routes = [
  {
    path: "",
    component: HomePageComponent,
  },
  {
    path: "newPage",
    component: NewPageComponent,
  }
];

@NgModule({
  imports: [RouterModule.forRoot(routes)],
  exports: [RouterModule]
})
export class AppRoutingModule {}

And, let your default url be localhost:4200, then, on url, localhost:4200/newPage you will see the new component loaded ie NewPageComponent mentioned in Routes .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM