I don't know the philosophies underlying angular, especially regarding testing, well enough to know if I should prefer to use router.navigate() in Components or Services.
For example, suppose you have a LogInComponent that manages your log in form and an AuthService that handles talking to the server. When a user successfully logs in, you want to redirect them from the log in screen to the home page of the application. Is it best to do that in LogInComponent or AuthService?
Definitely Component, the Services are only supposed to bring the data you want, it should not know anything about the Presentation, whether its a Single Page Application, a simple static pages, a hybrid or native app, let alone how you navigate between them, that way you can change this later and you can reuse your whole services package.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With