chamara
chamara

Reputation: 12709

Angular 7 Navigate from component to another

enter image description here How do I navigate from new-contract component to customer-details component?

I tried following on the new-contract component but it keeps navigating to 404.

this.back_url = '/customer/customer-details 
this.router.navigate([this.back_url]);

Upvotes: 0

Views: 153

Answers (3)

Karan Bains
Karan Bains

Reputation: 99

Since you are navigating with url string, you must use Router.navigateByUrl function.

  this.router.navigateByUrl('/customer/customer-details');

Upvotes: 0

Sivaramakrishnan
Sivaramakrishnan

Reputation: 739

Use router to navigate between pages. Import the component in the routing module and do like this

this.router.navigate('customer/customer-details')

Upvotes: 0

Pardeep Jain
Pardeep Jain

Reputation: 86790

Try this -

this.router.navigateByUrl(/customer/customer-details);

Upvotes: 1

Related Questions