0

I am beginner in angular 2 and i am trying to do some routing practice. I have a button on productDetailComponent. Now when i click on the button, it want the page to route to moreDetailComponent.

export const TutorialRoutes: Routes =[
i w
  {
    path: 'Company',

    component: CompanyComponent,
    children: [
      {path: '', redirectTo: 'people'},
      {path: 'price', component: PriceComponent},

        {path: 'products', component: ProductComponent,

        children:[

            {path: '', redirectTo:'product-details'},
            {path:'product-details', component:ProductDetailsComponent},
            {path:'more',component: MoreDetailsComponent}

        ]

        },


    ]

  }
];

// button to move to page (moreDetailsComponent)

<button routerLink="more">Add</button>

1 Answer 1

1

A guess (because the question isn't quite clear to me)

<button routerLink="../more">Add</button>
Sign up to request clarification or add additional context in comments.

10 Comments

the url change to from /details to /more but the page did not change.
The route should be Company/products/product-details and change to Company/products/more if the button is in the ProductDetailsComponent. If the button is somewhere else, it's not supposed to work.
Yeah the button is in the ProductDetailsComponent. When i click on the button, the url changes alright but the page remains does not navigate to the moreDetailsComponent
Do you get any error in the browser console? Are you using the express server or some other?
There is no error in my console.. I am using my inbuilt server.
|

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.