【发布时间】:2015-03-05 05:43:10
【问题描述】:
免责声明:主要新手警告!
我已经按照this 教程成功设置了一个 Rails 后端/Ember 前端项目。
我的路由器是
import Ember from 'ember';
import config from './config/environment';
var Router = Ember.Router.extend({
location: config.locationType
});
Router.map(function() {
this.resource('contacts', function() {
this.resource('contact', { path: '/:contact_id' });
});
});
export default Router;
现在我想设置根据联系人的姓氏仅查找某些联系人的可能性,所以我关注了official docs for specifying query params。
我已经修改了我的 app/routes/contacts/index.js 路由,现在它看起来像这样:
import Ember from 'ember';
export default Ember.Route.extend({
queryParams: {
lastName: {
refreshModel: true
}
},
model: function(params) {
return this.store.findQuery('contact', params);
}
});
和app/controllers/contacts.js
import Ember from 'ember';
export default Ember.ArrayController.extend({
queryParams: ['lastName'],
lastName: null,
});
不幸的是,params 没有填充,即使我在浏览器中指定了查询参数。更准确地说,params 对象如下所示:
其中似乎没有任何我感兴趣的内容。
然而,查询参数信息被以某种方式传播到视图,所以我感到有些困惑。如何为我的路线中的模型挂钩填充params?
【问题讨论】:
标签: javascript ruby-on-rails ember.js