I am setting isActive in setupController:
App.EntryRoute = Ember.Route.extend
setupController: (controller) ->
controller.set('isActive', true)
I would like to remove it when the route is changed.
What is the best way to do this? Are there any hooks for when the controller is removed?
Edit: It seems I asked the wrong thing. I want to trigger this when the model is changed, meaning deactivate will not work, as it is only changed when you leave the route.
I would like to remove it when the route is changed. What is the best way to do this?
Probably what you are looking for is the route's deactivate hook. While not strictly "the opposite" of setupController, deactivate will be called whenever the router exits the route. Docs here: http://emberjs.com/api/classes/Ember.Route.html#method_deactivate
As @Mike Grassotti already mentioned deactivate and his counterpart activate are what you might need to solve your problem, this is how you EntryRoute could look like:
App.EntryRoute = Ember.Route.extend
activate: () ->
@controllerFor('index').set('isActive', true)
deactivate: () ->
@controllerFor('index').set('isActive', false)
hope it helps
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