我正在编写一个组件,需要访问当前路由的模型;
在组件模板中,我想这样做:
{{#each color in model}}
...
{{/each}}
我将在不同的路由中使用此组件,并使用不同的模型。
如何在组件内访问当前路由的模型?
Ember.Component.extend({
didInsertElement: function() {
console.log(this.get('controller') //this is not the route's controller
console.log(this.get('controller').get('model')); //undefined of course
}
});