Practices - Do you use client-side routing?

Updated by TiagoAraujo 6 years ago. See history

123
No component provided for introEmbed

This is easily fixed with Angular ’s routing capabilities, and implementing it in your SPA will confer several advantages:

  • URLs can be copy-pasted and shared
  • Page refreshes work as expected
  • Less prone to errors
  • Better separation of concerns (navigation vs page state)
Image

❌ Figure: Bad example - The blog post component is choosing components based on the state of the component

A better way is to set up routes, and use a router (the first-party component router is great for this) to manage your components:

✅ Figure: ![Good: Setting up declarative routes and outlets gives a good user experience, persistent URLs, and fewer moving parts](/uploads/rules/use-client-side-routing/client-side-good.png)

Acknowledgements

Steve Leigh
Duncan Hunter
Related rules

Need help?

SSW Consulting has over 30 years of experience developing awesome software solutions.

We open source.Loving SSW Rules? Star us on GitHub. Star