Currently i having a route which is use to findAll the record from a model. But the result comeback as an array so in the template I used {{#each}} to loop them. Originally it comeback two records in the array which is the correct behavior. But whenever i try to transition to another route and transition back it will comeback 4 records which is duplicate. It will multiple each time when i try to transition back. I’m not sure which part is missing or having mistake that cause that behavior. Or variable must be destroy when leave the route?
Route
@task(function* (){
try {
let companyList = yield this.store.findAll('list-company');
return {
companyList: companyList,
}
} catch (e) {
this.intermediateTransitionTo('error', e);
throw (e);
}
}).restartable() loadModelTask;
model() {
try {
return this.loadModelTask.perform();
} catch (e) {
throw (e);
}
}
setupController(controller, model) {
this._super(controller, model);
controller.set('companyList', model.companyList);
}
Template
{{#if loadModelTask.isRunning}}
////code
{{else}}
{{#each companyList as |comp|}}
////code
{{/each}}
{{/if}}
Before transition when the route is called

After transition back from other page, the record is duplicated
1 post - 1 participant
