Reputation: 344
On application initialization , all the controllers are initialized by Ember. After working with any of the controllers, it retains its values, that becomes a problem while reusing the controller. I would wanna know :
PS : Please don't misunderstand "reusing controllers". All I want is to use the same controller without the previously entered values from any previous task.
Upvotes: 0
Views: 399
Reputation: 8389
Controllers are intended to be long-lived and hold application state even as their views may blink in and out of existence. In a typical Ember app, controllers are created once and live for the life of the app, hence the reasoning for initializing them all at app initialization time.
For an easy way to "reset" a controller, you could use an Ember.ObjectController
, that proxies gets and sets of properties not defined on the controller the object you set as the content
property. To reset the controller, just set content
to a fresh object.
Upvotes: 2