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

时间:2015-03-03 13:28:01

标签: 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: 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

问题:如何在页面刷新后重置控制器内的变量,以便我可以从路径再次加载它们。

0 个答案:

没有答案