In my Ember template, I render an arbitrarily-sized array of displayItems like so:
<script type="text/x-handlebars" id="display">
<h1>{{name}}</h1>
<hr>
<div id="display-items">
{{#each displayItem in displayItems itemController="chart"}}
{{render "chart" displayItem}}
{{/each}}
</div>
</script>
However, I need to initialize some properties on the chart controller before the chart view renders. I know that for predefined view and controller structures, you can use the setupController hook on a route, but since these controllers are created dynamically, I thought I could use the chart controller's init property like so:
...other controller code
init: function() {
var self = this;
self._super();
self.get("views")
.then(function(views) {
self.set("currentView", views.objectAt(0));
});
}
...
But although the init hook is called, it is called too late--the view has already rendered with undefined values. Is there a way to setup dynamically-created controllers before their views render?