There appear to be two alternative ways to set the initial state of a controller in EmberJs:
When is it appropriate to use one over the other? Are they equivalent?
Generally speaking, Controller#init gets called only once when the (usually singleton) controller is created, while Route#setupController is called each time the route is entered.
Any model-related properties should be set from Route#setupController. Other default setup can be handled in Controller#init.
In most Ember apps I have worked on, Route#setupController is used more often than Controller#init.
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