Angular πŸ‡ΊπŸ‡¦ - practical notes
1.63K subscribers
1.6K photos
1 file
532 links
Angular - practical notes

This group is for posting practical notes for Angular developers. Mostly all posts are for quick implementation https://t.me/angular_practical_notes (Commenting on posts only in ENG and UA langs here). Welcome!
Download Telegram
πŸ“„ Angular Named Router Outlets

#angular #router #outlets

<!-- wrapper-layout.component.html -->

<div class="container">
<div class="row">
<div>
<left-side></left-side>
</div>
<div>
<router-outlet
name="showright"
></router-outlet>
</div>
</div>
</div>


/** routing.module.ts */

{
path: 'connect',
component: WrapperLayoutComponent,
children: [
{
path: '',
component: RightSideComponent,
outlet: 'showright'
},
]
},



// component navigation action

this.router.navigate([
'/connect',
{ outlets: { showright: ['user-info'] } }
]);

βœ… Article link
πŸ‘3❀1πŸ”₯1
πŸ§ͺ Navigating Angular Apps: RedirectCommand

#angular #router

Here are two common scenarios where this technique is particularly useful:

- Redirecting to a 404 Page for Unknown Resources: When attempting to access an unknown resource, it’s typical to redirect to a 404 page. The expected behavior here is akin to skipLocationChange, where users can see the URL of the unknown resource, allowing them to identify and correct any typos. However, with the UrlTree technique, the URL displayed after the redirect shows /404.

- Performing a 301 Redirect to a Resource’s Canonical URL: In cases where a resource’s URL can be renamed or aliased, performing a 301 redirect to its canonical URL is beneficial. Ideally, this should behave like replaceUrl, where users see the canonical URL without the option to navigate back to the obsolete or aliased URL. Yet, with the UrlTree technique, users can still navigate back to the obsolete or aliased URL.



🚩 > Angular 18

βœ… Article link
πŸ‘2
🌐 πŸ–€ `CanMatch` Interface in Angular Router (2024)

#angular #guard #router #routing

The CanMatch interface is a part of Angular’s routing mechanism that enables conditional route matching. It provides a way to define guard logic that runs before the router tries to activate a route. If all CanMatch guards return true, the router proceeds with navigation to the route. If any guard returns false, the route is skipped for matching, and the router evaluates other route configurations.


βœ… Article link
Please open Telegram to view this post
VIEW IN TELEGRAM
Please open Telegram to view this post
VIEW IN TELEGRAM
πŸ‘2