0
votes

I need to do a master-details view when I click on a row. I have the code in a branch here's the commit link.

  let urlDetail = this.router.generate('energy-details', {model: this.model});
  this.router.navigate(urlDetail);

This works, but the query string is awful. How do I send the model across in memory?

This was really hard to find an example for. https://github.com/softchris/aurelia was the best one. Is there a better way to do master-detail views? I'm new to Aurelia.

http://localhost:5000/#/energy-details?model%5BdataSeriesId%5D=ES&model%5BcountryId%5D=392&model%5BcountryName%5D=Japan&model%5BtransactionCode%5D=01&model%5BcommodityTransactionId%5D=ES01&model%5BcommodityTransactionName%5D=Electricity%20-%20solar%20production%2C%20public&model%5Byear%5D=2000&model%5Bunit%5D=Kilowatt-hours%2C%20million&model%5Bquantity%5D=2&model%5BfootnoteSequenceId%5D=0.

1

1 Answers

2
votes

Reconsider if you just don't want to use id. Quite often in a mater-details you need to make a new query to get more data anyway.

If not possible for your use case, maybe it makes sense to have a DataManager singleton.

  • Create a DataManager class that you inject in your List and Detail ViewModel. By default every injected class is a singleton in aurelia
  • In the list ViewModel, make sure your data is saved in the DataManager
  • Routing by passing the id only
  • In the details ViewModel call your method getModelById(id) of the DataManger