Jump to content
Main menu
Main menu
move to sidebar
hide
Navigation
Aphorismen
Applications
Business Economics & Admin.
My Computers
Cooking
Devices
Folders
Food
Hardware
Infos
Software Development
Sports
Operation Instructions
Todos
Test
Help
Glossary
Community portal
adaptions
Sidebar anpassen
Wiki RB4
Search
Search
Create account
Log in
Personal tools
Create account
Log in
Pages for logged out editors
learn more
Contributions
Talk
Editing
Angular
(section)
Page
Discussion
English
Read
Edit
View history
Toolbox
Tools
move to sidebar
hide
Actions
Read
Edit
View history
General
What links here
Related changes
Special pages
Page information
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
===Routing=== * see [https://indepth.dev/tutorials/angular/indepth-guide-to-passing-parameters-via-routing for a detailed description] or * [https://angular.io/guide/router-tutorial-toh#route-parameters Angular Router Tutorial] In Angular, the best practice is to load and configure the router in a separate, top-level module that is dedicated to routing and imported by the root AppModule. By convention, the module class name is <code>AppRoutingModule</code> and it belongs in the <code>app-routing.module.ts</code> in the <code>src/app</code> folder, which contains a routing table (sequence is important!!!): const routes: Routes = [ { path: '', component: LoginComponent}, // app root { path: 'bookmarks/menus/:id', component: MenuComponent}, { path: 'welcome/:name', component: WelcomeComponent}, // parameter { path: '**', component: ErrorComponent} // matches everything ]; and in template: <router-outlet></router-outlet> and in code: // see bookmarks.component.ts this.router.navigate( ['/menus', this.currentSubMenuObjects[subMenuIndex].uuid], // setting required route parameter { queryParams: { mode: "view"} } // setting query parameter ); ====Route Information==== To get information of the route in the target component include in the ctor: private route: ActivatedRoute, and // by snapshot this.uuid = this.route.snapshot.paramMap.get('uuid'); this.mode = this.route.snapshot.queryParamMap.get('mode'); // by observer this.id = +this.route.snapshot.params['id']; // to get parts of the this.route.queryParams.subscribe(params => {this.parentId = +params['parentId'];}); // to get query params
Summary:
Please note that all contributions to Wiki RB4 may be edited, altered, or removed by other contributors. If you do not want your writing to be edited mercilessly, then do not submit it here.
You are also promising us that you wrote this yourself, or copied it from a public domain or similar free resource (see
Uwe Heuer Wiki New:Copyrights
for details).
Do not submit copyrighted work without permission!
Cancel
Editing help
(opens in new window)
Toggle limited content width