Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Using a non-ID dynamic parameter with the ember router v2

Has anyone messed around with using a non-ID parameter with the new ember router?

Back with the older version of the router, it seemed like an easier thing to do, since you had access to the serialize and deserialize methods on a route. In effect you could theoretically deserialize a non-ID attribute of the model into the params hash, and you could serialize an object from that non-ID attribute using the deserialize and serialize methods on the route, respectively. From my understanding the serialize and deserialize methods are no longer public, which makes this a bit trickier to handle..

like image 318
Han Avatar asked Feb 18 '23 21:02

Han


1 Answers

With the new router, you still have access to serialization and deserialization.

  • deserialize has been renamed model, and it gets the params as a parameter. If you return an Ember Data object from model (or any other Promises/A+ compatible promise), the rest of the hooks will not run until the object has loaded.
  • serialize is still named serialize. It takes the model (the object passed to the linkTo helper or the transitionTo method) as its first argument, and should return a hash of parameters.
like image 150
Yehuda Katz Avatar answered Mar 23 '23 12:03

Yehuda Katz