Note: If someone is updating their routes to component-less routes after watching this video, just make sure to check if there is any router.navigate() using relative paths inside those child components (e.g. router.navigate(['../parent', { relativeTo: currentRoute }])). That may need to be updated.
Дякую за цікаве та корисне відео 👍 Вперше прийшов до цього методу, коли потрібно було навісити резолвер на декілька роутів та не хотілось копіпастити Якби на інтервью запитали щось про "Component-Less and Empty-Path Routes" навіть не здогадався би про що мова)
Great video c: I have a small tip: at 6:19, you can put your cursor on the `=>` and press `Ctrl + .` which allows you to quickly add `return` to the arrow function c:
Interesting video. I found myself using componentless routes for routed modals. That way angular doesn't complain about route not existing. What I haven't realized is that it worked only because I used it in lazy loaded modules. I'm currently searching for a better solution.
thanks, very interesting, never used this feature before. Before watching this video I supposed this was about routes that do not show anything (empty or dummy template) but just redirect user to another page. For example when user click some confirm link in email, the frontend just post data to the server and redirect to another (public) page instantly.
Hey, thanks for the video! I don't use Angular, but it would be interesting to try. In real life apps, developers create Route objects as literals in the routing files? What about type safety and possible typos in the routerLink path directive?
Great content, that technique could be useful in some scenarios. I really like the idea of providing in-depth angular form course. I hope oneday to see similar course about angular PWA, imo there is a lack of up-to-date materials to become comfortable with the topic.
Thank you very much for your work, very interesting and informative material. can you make a series of videos about the ubiquitous language and domain oriented design (ddd) in Angular? What is it, how is it customary to implement it in Angular, what difficulties can there be, what will it give in the end .... Once again, thank you very much for your work.
I learned resolvers once, then I heard its bad because it is synchronous and its better to load data in component. Could You clarify this? Seems like good feature... Anyway great explanation as always. Its awesome you describe use case before exmplaining solution
Resolvers are great, especially when you implement loading state handling. With a little bit of work you can easily create nice user experience around that. You can use resolvers for essential data required for component withoit which it will not work properly. This way you don't have to repeat loading stste logic in all components.
Great video!! I guess if the user had a global logout button and press it in one of those child routes, since the canActivate guard it's not triggered, could be a problem, isn't it? In such a case, what would happen with the user resolver? Would it return the empty user or would it not be reactivated?
No, it should not be a problem. If you log out you usually don’t need to trigger canActivate guard. You just remove authentication token, etc and redirect to “login” page
@@DecodedFrontend In some cases removing the authentication token can't work properly. For example you have a form and want to ask the user if he sure to logout without saved shanges. It makes sense to logout via /logout route and use the canDeactivate guard.
You can inject Router in the Guard and navigate to a new url from within the guard. In this case with the isAuthenticated$ observable you can pipe it through a tap function that navigates to /login if the value is false
"it's easy to forget to install the guard when there are many routes"? Seriously? This structure looks difficult even for the eyes. Yes, the code will be reduced but what is the profit? When you have at least 10 routes(and using more than one guard for all) with such a structure, you will be amazed by the complexity structure. But yeah, cool approach if you're alone on the project.
Imagine you have a schematic which add some page with nested components to your project. Also this schematic add a new route with this page. In this situation current approach is very useful, such as you don't want have a guard logic into schematic and just describe it into your routing module.
Hi, Thanks for the feedback. You can always extract the component-less route config in the separate file, give a meaningful name to that constant and just import it to the main router config, so the main config will remain lean and readable.