I am new to Ember and have a question regarding where to put common code. Consider a simple scenario. I have an AJAX request and I want to use the response in multiple places (say a route and in some controller OR 2 different controllers)
I have 2 questions;
- In Ember, can I access any controller (say X.js) from any other controller (say Y.js), by just using this.controllerFor(this.routeName)
- If the above is true, is that a better approach for common code (i.e. having a property in X controller to save the common API response) and then using it in another controller Y OR Should I use Ember Service for the common code and through dependency injection, consume the common code/API response ?
What is the correct way for this use case ?
Aucun commentaire:
Enregistrer un commentaire