Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

When using RouteProvider separately to the StateProvider, state not updated on route param change #128

Open
mcampster opened this issue Dec 8, 2014 · 3 comments
Labels
Milestone

Comments

@mcampster
Copy link

When defining a state independently of the route e.g. define the state with the $stateProvider, then map the route to the state using the $routeProvider, the state is not correctly reloaded when one of the route params changes e,g

$stateProvider.state('contact', {
                views: {
                    'main': {
                        template: 'contact.html',
                        controller: 'contactController'
                    }
                },
            })

$routeProvider.when('/contacts/:contactId', { state: 'contact') })

I would expect that when the 'contactId' changes, the state should be reloaded, as it is when you declare the route on the state itself...

$stateProvider.state('contact', {
                route: '/contacts/:contactId',
                views: {
                    'main': {
                        template: 'contact.html',
                        controller: 'contactController'
                    }
                },
            })

The reason I am declaring the routes using the routeProvider is so that we can map 1 or more routes to the same state. If there is another way of doing this, perhaps the above issue would not need solving?

@mcampster mcampster changed the title Controller & View not updated when route param changes When using RouteProvider separately to the StateProvider, state not updated on route param change Dec 8, 2014
@jeme
Copy link
Contributor

jeme commented Dec 8, 2014

@jeme jeme added the bug label Dec 9, 2014
jeme added a commit that referenced this issue Mar 8, 2015
jeme added a commit that referenced this issue Mar 8, 2015
…t so STATE_CHANGE is fired on reload optional.
jeme added a commit that referenced this issue Mar 8, 2015
jeme added a commit that referenced this issue Mar 8, 2015
@jeme
Copy link
Contributor

jeme commented Mar 10, 2015

There is still a piece missing in this on for it to work with no routes on the state at all.

But for the more conceptual part, I would still recommend giving a route to an actual state... Which will act as a main route for that state... Reason being that it enables URL generation for states...

You can still add additional routes pointing to the state after that. So in essence you would have:

$stateProvider.state('contact', {
                route: '/contacts/:contactId',
                views: {
                    'main': {
                        template: 'contact.html',
                        controller: 'contactController'
                    }
                },
            })

$routeProvider.when('/anotherurl/:contactId', { state: 'contact') })

@jeme
Copy link
Contributor

jeme commented Mar 10, 2015

and Example: http://plnkr.co/edit/UtuBVXrr89cizzqz4IFU?p=preview
(Running current latest from master, I wan't this issue fully fixed before I do a release)

@jeme jeme added this to the v0.6.16 milestone Mar 10, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants