For example: http://localhost:3000/#/report/123456
How do I get the "123456" part from the url with Aurelia?
Hope you can help me, couldn't find anything useful in the docs.
you can get the submitted params in the activate method of the router (in your viewmodel)
activate(params) {
return this.http.fetch('contacts/' + params.id)
.then(response => response.json())
.then(contact => this.contact = contact);
}
found in a nice blogpost here: http://www.elanderson.net/2015/10/aurelia-routing-with-a-parameter/
You have to have a route defined for it:
{
route: ['report/:id'],
moduleId: './report',
title: 'Report',
name: 'report'
}
Then in your view model, you can get the id
from the params
object:
activate(params) {
console.log(params.id);
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With