jeudi 1 février 2018

Ember.js - HOWTO load a subclass data model into a superclass's route

Is there a way to load a subclass data model into a superclass's route?

As an example, I have a superclass named Vehicle and a subclass named Car.

I have route like this:

/vehicle/21/edit

And in this instance, Vehicle #21 is a Car. Accrodingly, my API returns the following payload data:

{"car": {/* lots of data */}}

When the route vehicle.edit tries to load this data, I get the following error:

Error while processing route: vehicle.edit payload.data is null

I can work around this by changing my API so that it uses vehicle as the root node in the JSON response, but I was wondering if Ember has a way to automatically cast a subclass into a superclass (e.g., load the car JSON response into a Vehicle instance).

Thanks in advance!




Aucun commentaire:

Enregistrer un commentaire