vendredi 8 mars 2019

findAll with a property defined by parent

2 components, 1 parent 1 child. The parent is a list with buttons. User clicks the button and the child editor becomes visible and the variable listType gets passed to the child from the parent.

I want a property to do a findAll in the child based on the listType property, e.g.

listType:null,
records: this.get('store').findAll(this.get('listType'));

problem is when the child editor first inits listType is undefined and takes a moment for the data to be passed down from the parent. How should I compute the records based on the listType so that it can dynamically change records when a different listType is selected from the parent list and not crash when the listType property is undefined on init?

This might seem a little weird but I have 20 different listTypes and being able to compute records this way will save me from having to create an additional 40 files to save and delete the model types required.




Aucun commentaire:

Enregistrer un commentaire