Resolve or Die: Error Handling Strategies for Loading Data
摘要
Angular provides a powerful mechanism for controlling access to routes in your application – Route Guards. These sentinel-like entities effectively ensure that certain conditions are met before a route is activated. Are you wondering if a user is authenticated? A Route Guard can verify that. If the user isn’t authenticated or doesn’t belong to the appropriate authorization group, access to the guarded route is denied. Route Guards embody the Single Responsibility Principle, are easily mockable for unit tests, and significantly enhance the security of your application. But this raises a question – where do Route Resolvers fit into this picture?