Reputation: 21
In the very new release of UI-Router1.0.0-alpha.1 Christopher Thielen announced dynamic parameters. For my understanding, if a param is configured to be dynamic, when changing it from the controller the URL should change accordingly. I tried several methods and couldn't make this happen. There doesn't seem to be binding between $state.params.myParam and $stateParams.myParam.
Can someone please share a working example, or tell me if it is indeed not working?
Thanks
Upvotes: 0
Views: 479
Reputation: 21
It is not enough to just change the dynamic parameter. The location changes when performing state transition, using ui-sref
or $state.go()
.
When transitioning to the current state where the only change is in parameters that are defined as dynamic, the controller is not reloaded.
example:
$stateProvider.state({
name: 'home',
url: '/home/:dynamicParam',
template: template,
controller: controller,
params: {
dynamicParam: {
dynamic: true
}
}
});
Change the param using: ui-sref=".({ dynamicParam: newVal })"
or $state.go('.', { dynamicParam: newVal })
Here's a plunker made by Chris Thielen that demonstrates this.
Upvotes: 1