Ember.js controller variables reseting after page

2019-09-02 06:16发布

问题:

Using Ember.js:

I have a Route

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"),
    });
  }
});

All those .get('[variable name]') are variables inside QueryData controller.

Update: added controller

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); 
    }},

PROBLEM: After page refresh I lose those variables ofcourse because they are declared as null again inside the controller.

QUESTION: How can I not reset the variables inside the contorller after page refresh so that I can load them again from Route.