0

can you tell me if these considerations are completely correct?

I have this routes: {path:'home:id', Component:'HomeComponent}, {path:'about', Component:'AboutComponent},

I can navigate to the routes path using these two methods:

1)first method: html template(routerLink directive)

<a [routerLink]= "['/home',2]"></a>

When user click a tag, this final URL is generated: domain_name/home/2. The number 2 is the value parameter that replaces the id paramter (path:'home:id'......}. Furthermore, when the user click a tag, the first route will be navigated {path:'home:id', Component:'HomeComponent} and HomeCompnent will be actived and displayed.

2)second method:

Navigating programmatically:

route to navigate to: {path:'about', Component:'AboutComponent}

router.navigate(['/about'])

In this second case, when this statement will be executed, this final URL is generated: domain_name/about, second route will be navigated {path:'about', Component:'AboutComponent} and AboutCompnent will be actived and displayed.

In this examples, in routerLink directive and navigate method, I have passed an absolute path in the array argument, because it starts with a slash. For absolute paths, the router starts matching from the root path at the beginning of the route configuration.

Is everything correct for you or are there errors? It's important

Thanks

1 Answer 1

0

this 2 method i am generally used check it

Method:

1)firstmethod

{path: "",component: HomeComponent},
{path:':id', Component:'HomeComponent},

{path:'about', Component:'AboutComponent} and called in html

<a [routerLink]="Home/id"></a>
<a [routerLink]="about"></a>

2)secondmethod

route same as first method
router.navigate(['/about']);
Sign up to request clarification or add additional context in comments.

5 Comments

in first method for id you can call on different way so i suggest you use in for pass id like :id for this use my routing way.
could you re-check my post?, I made some changes. Thanks
Ionic 4 tabs navigation is based on angular routing?
yes its same as like angular routing check this link ionicRoute
I'm sorry, I take this opportunity to ask another question; In Ionic tab navigation, the value of <ion-tab-button tab="tab1"> tab attribute must match with value of path key in a route configuration { path: 'tab1', component:Tab1Page. right?

Your Answer

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

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.