mardi 5 mai 2020

how to reduce the load in model hook in Ember

I have a routes/paper.js file which has below model hook

model(params,transition){
   let user = store.getRequest('user','paper/user')
   let address = store.getRequest('address','paper/address')

return RSVP.hash({
   user,
   address
}).then((model) => {
    set(model, 'address_name', get(model.address, 'name'));

    return ...model
})

}

I want to reduce the load in model hook by moving the api request to controller and use it in setcontroller . but the model is not having the data , please find below my modification

//controller/paper.js

testerfunction(params){
 let user = store.getRequest('user','paper/user')
   let address = store.getRequest('address','paper/address')
   let paperId = params.paperID

return RSVP.hash({
paperID: paperID,
   user,
   address
}).then((model) => {
    set(model, 'address_name', get(model.address, 'name'));

    return ...model
})

}


//routes/paper.js 


model(params,transition){

}


setupController(controller,model) {
 testerfunction(get(this,'model.params');
}

but my page render is blank




Aucun commentaire:

Enregistrer un commentaire