关于Ember方法modelFor的几个问题
我在组件中使用它的尝试失败了:
//info component
model(params){
return this.store.createRecord('info');
},
user: this.modelFor('user'),这段代码通过以下错误破坏了整个应用程序:
ember.debug.js:4875 Uncaught TypeError: this.modelFor is not a function我发现自己经常想要在组件中使用方法,或者想要访问组件逻辑中的多个模型--有谁知道一个很好的资源来对自己进行这些最佳实践的教育?
谢谢!
发布于 2016-03-29 20:00:00
modelFor不是组件中的函数。必须通过要实现组件的模板中的参数将模型传递到组件中。
{{my-component model=model}}组件文档
modelFor是路由中的一个函数。
路线文件
返回多个模型的
路由
model: function() {
let model1 = this.modelFor('x'),
model2 = this.modelFor('y');
return {
model1: model1,
model2: model2
};
}https://stackoverflow.com/questions/36290296
复制相似问题