Routing
Moving from one WebPage to another WebPage.
Routing is used to navigate from one component to another component in angular.
Steps:
1.Configuring the route path in app-routing
2.Adding router-outlet in app.component.html
3.Add routing links in ts-template
4.import AppRoutingModule in app.modules
<router-outlet> </router-outlet>
- RoterLink
- Navigate
- RoterLink
without param :
<li><a [routerLink]="['product']>Product</a></li>
with param :
<li><a [routerLink]="['product']" [queryparams]="{page:2}" >Product</a></li>
- Navigate
ctor (private _servRouter : Router, ){}
without param :
onBack(){
this._servRouter.navigate(['/ChildDashboardComponent']);
or
this._servRouter.navigateByUrl('/ChildDashboardComponent');
}
with param :
onBack(){
this._servRouter.navigate(['/ChildDashboardComponent']
{ queryParams:{tabNumber: +this.tabNumber,mainDocumentId: +id},
);
}
Comments
Post a Comment