How to generate a unique controller for views?


#1

Is there a way to create a new controller object every time when view is rendering? This approach would be more convinient for me, because i deal with modal windows. Thanks for your answer.


#2

You could instantiate a new controller on init, for example:

App.ModalView = Ember.View.extend({
  setupController: function() {
     var controller = Ember.Controller.create(/* customize your controller here */); 
     this.set('controller', controller);
  }.on('init') // this method will be called when this view is instantiated
});

That would give you a custom controller for this view.