I know that I can get route params in components with the “activate” hook, but we would like to have no routing information in our components. We did that in AngularJs with Angular Ui Router and we were pretty happy with it. In AngularJs it was like:
Because of the silence in this thread and further investigations by me, I assume that there is no easy solution available with standard aurelia features. Does anyone have an idea where I should start to implement this with a hook, plugin or something similar?
Hmm perhaps @jwx can give you some hints on where to start.
From a testing perspective though keep in mind that moving the assigning away could create additional overhead, which was also troublesome with AngularUi router
@elitastic you can create a custom decorator to do what you what. Imaginary usage would look like this:
@fromActivate({
// userId is the target bindable property we want to assign a value to
userId: (params) => params.userId,
...
})
export class UserDetail {
}
What that @fromActivate decorator does is simply create or override method activate on the view model to do the assignment. The implementation would look like this:
My original goal went one step further, to separate that routing information completely away from the component, to let the route define the link between route params and component bindables.