{"id":22542412,"url":"https://github.com/mohitjaiswal28/routing-angular","last_synced_at":"2026-05-04T02:34:17.290Z","repository":{"id":253528446,"uuid":"843780241","full_name":"mohitjaiswal28/Routing-Angular","owner":"mohitjaiswal28","description":"Angular routing is a powerful feature that allows you to navigate between different components or modules within your Angular application. ","archived":false,"fork":false,"pushed_at":"2024-10-27T11:57:34.000Z","size":1368,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-02-02T08:29:35.571Z","etag":null,"topics":["angular","path-parameters","queryparameters","queryparams","routing"],"latest_commit_sha":null,"homepage":"https://mohitjaiswal28.medium.com/routing-in-angular-0bc54af59caf","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/mohitjaiswal28.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-08-17T11:53:57.000Z","updated_at":"2024-10-27T12:03:16.000Z","dependencies_parsed_at":"2024-10-27T11:41:30.455Z","dependency_job_id":"11515098-13dc-42d7-9724-be73c396ef8e","html_url":"https://github.com/mohitjaiswal28/Routing-Angular","commit_stats":null,"previous_names":["mohitjaiswal28/routing-angular"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mohitjaiswal28%2FRouting-Angular","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mohitjaiswal28%2FRouting-Angular/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mohitjaiswal28%2FRouting-Angular/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mohitjaiswal28%2FRouting-Angular/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mohitjaiswal28","download_url":"https://codeload.github.com/mohitjaiswal28/Routing-Angular/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245991561,"owners_count":20706126,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["angular","path-parameters","queryparameters","queryparams","routing"],"created_at":"2024-12-07T13:10:20.091Z","updated_at":"2026-05-04T02:34:12.251Z","avatar_url":"https://github.com/mohitjaiswal28.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Angular Routing 🌐\n\nAngular routing is a powerful feature that allows you to navigate between different components or modules within your Angular application. It provides a seamless user experience by dynamically updating the content without reloading the entire page.\n\n## Path vs Query Parameters\n\n![Path vs Query Param](./Path_Query_Param.png)\n\n- [For more detail, read this Medium article by @AveryCS\n  ](https://medium.com/@averydcs/understanding-path-variables-and-query-parameters-in-http-requests-232248b71a8)\n\n# 1. Path Parameters 📍\n\n### 1.1 Passing path parameter in routes:\n\n```\n\u003ca [routerLink] = ['book', bookID, 'author', authorID]\u003e\n```\n\n```\nconst routes: Routes = [\n    {path: 'books/:boodID/author/:authorID', component: BookComponent}\n]\n```\n\n### 1.2 Retrieving path parameter from routes:\n\nThere are two ways for retrieving the path param from the routes:\n\n- `snapshot` (for static route till the component is active and no change in route)\n- `observable` (for dynamic route)\n\n- Using snapshot 📸\n\n```\nthis.bookIDfromRoutes = this.routes.snapshot.paramMap.get('bookID')\nthis.bookIDfromRoutes = this.routes.snapshot.params['bookID']\n```\n\n- Using observable 📡\n\n```\nthis.routes.paramMap.subscribe(params =\u003e {\n    this.bookIDfromRoutes = params.get('bookID')\n})\n\nthis.routes.params.subscribe(params =\u003e {\n    this.bookIDfromRoutes = params['bookID']\n})\n```\n\n# 2. Query Parameters 🔍\n\n### 2.1 Passing query parameter in routes:\n\n```\n\u003ca [routerLink] = \"['product']\" [queryParams]={search: searchValue}\u003e\n```\n\n```\nconst routes: Routes = [\n    {path: 'product', component: ProductComponent}\n]\n```\n\n### 2.2 Retrieving query parameter from routes:\n\nThere are two ways for retrieving the path param from the routes:\n\n- `snapshot` (for static route till the component is active and no change in route)\n- `observable` (for dynamic route)\n\n- Using snapshot 📸\n\n```\nthis.product = this.routes.snapshot.queryParamMap.get('search')\nthis.product = this.routes.snapshot.queryParams['search']\n```\n\n- Using observable 📡\n\n```\nthis.routes.queryParamMap.subscribe(params =\u003e {\n    this.product = params.get('search')\n})\n\nthis.routes.queryParams.subscribe(params =\u003e {\n    this.product = params['search']\n})\n```\n\n# 3. Lazy Loading 🔁\n\nAngular only loads modules as needed, rather than loading all modules when the application launches.\n\n# How to Clone and Run this Project 🖥️\n\n1. Clone the repository:\n\n```\ngit clone https://github.com/mohitjaiswal28/Routing-Angular.git\n```\n\n2. Navigate to the project directory:\n\n```\ncd Routing-Angular\n```\n\n3. Install the dependencies:\n\n```\nnpm install\n```\n\n4. Run the application:\n\n```\nng serve\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmohitjaiswal28%2Frouting-angular","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmohitjaiswal28%2Frouting-angular","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmohitjaiswal28%2Frouting-angular/lists"}