0

I have to fix such solution: my url is http://localhost:8080/#/dashboard in my dashboard there are some features to load, for example when my url will be http://localhost:8080/#/dashboard/20 I must load cities which country id equals 20 and when my url will be http://localhost:8080/#/dashboard/20/1 I have to load districts which city id equals 1. so what is my problem: when I click some links and url changes to #/dashboard/20 I am loading cities, after that I click another one link and url changes to #/dashboard/20/1 but here my controller is refreshing and all data is loading again, I want to change url but not refreshing controller, when my cities are already loaded I must have opportunity to load only districts after that and not both of them again at once.

I tried window.history.pushState but it does not work, may be is there any way to disable and enable my $routeProvider?

any ideas?

1 Answer 1

2

The only way I see this working is referring to the same controller or using a factory/service to maintain your variables. The controllers will always change when the state changes if they are glued to them.

Edit: Btw, have you taken a look at ui.router? https://github.com/angular-ui/ui-router Here's the link. I find this much more helpful than the old $route

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.