Javascript 页面刷新后重新设置Ember.js控制器变量

Javascript 页面刷新后重新设置Ember.js控制器变量,javascript,ember.js,controller,routes,page-refresh,Javascript,Ember.js,Controller,Routes,Page Refresh,使用Ember.js: 我有一条路线 App.QueryDataRoute = Ember.Route.extend({ model: function(params) { return Ember.RSVP.hash({ propertyObject: this.controllerFor("cres").get("properties").findBy('title', params.propertytype_title), nrOfOffers:

使用Ember.js:

我有一条路线

App.QueryDataRoute = Ember.Route.extend({
  model: function(params) {
    return Ember.RSVP.hash({
        propertyObject: this.controllerFor("cres").get("properties").findBy('title', params.propertytype_title),
        nrOfOffers: this.controllerFor("queryData").get("nrOfOffers"),
        deal: this.controllerFor("queryData").get("deal"),
        price: this.controllerFor("queryData").get("price"),
        surface: this.controllerFor("queryData").get("surface"),
    });
  }
});
所有这些.get(“[variable name]”)都是QueryData控制器中的变量

更新:添加了控制器

App.QueryDataController = Ember.ObjectController.extend({
  id: null,
  property: null,
  deal: null,
  nrOfOffers: null,
  price: null,
  surface: null,

actions: {
    checkPropType: function (county, property, dealtype) {
        if(property.title ==="Apartment"){
                this.send('populateEstateData', property.title, dealtype.title, county.nrOfApartSale,county.avgPriceApartSale, county.avgSurfaceApartSale);
        }else if(property.title ==="House"){
                this.send('populateEstateData', property.title, dealtype.title, county.nrOfHouseSale,county.avgPriceHouseSale, county.avgSurfaceHouseSale);
        };  
    },

    populateEstateData: function(pProperty, pDeal,pNrOfOffers, pPrice, pSurface){
        this.set('id', 1);
        this.set('property', pProperty);
        this.set('deal', pDeal);
        this.set('nrOfOffers', pNrOfOffers);
        this.set('price', pPrice);
        this.set('surface', pSurface); 
    }},
问题:页面刷新后,我当然会丢失这些变量,因为它们在控制器中再次声明为null


问题:页面刷新后,我如何才能不重置控制器内的变量,以便可以从路由重新加载它们。

您可以发布控制器吗?添加了控制器,谢谢!你的方法是错误的。数据保存在控制器中,然后在模型钩子中再次返回给控制器。什么时候在控制器中设置这些属性?为了简单起见,我编辑了控制器。checkPropType由另一个控制器中的函数调用,该函数本身通过按Ember.select表单上的submit按钮调用。然后,所选的内容将转发到checkPropType,如county、property、dealtype。这些是填充变量所需的参数:id、property、nrOfOffers等等,。。。在QueryDataController中。QueryDataRoute中现在需要这些变量,以便在页面刷新后显示。希望我的解释不要太复杂。