Skip to content
This repository has been archived by the owner on Apr 12, 2024. It is now read-only.

Allow change browser URL without reinitialize controller status #1151

Closed
wants to merge 2 commits into from
Closed

Allow change browser URL without reinitialize controller status #1151

wants to merge 2 commits into from

Conversation

andresmoschini
Copy link

No description provided.

@mhevery
Copy link
Contributor

mhevery commented Sep 4, 2012

Thanks for your contribution! In order for us to be able to accept it, we ask you to sign our CLA (contributor's license agreement).

CLA is important for us to be able to avoid legal troubles down the road.

For individuals (a simple click-through form):
http://code.google.com/legal/individual-cla-v1.0.html

For corporations (print, sign and scan+email, fax or mail):
http://code.google.com/legal/corporate-cla-v1.0.html

@mhevery
Copy link
Contributor

mhevery commented Sep 4, 2012

I am trying to understand the use case here, but I am having troubles. Could you provide a better explanation as to why you need it?

@andresmoschini
Copy link
Author

Sure, go to http://commonjobs.apphb.com/angulardemo/employees and write something on "Búsqueda rápida" field (see changes in URL). Let me know if there is a better way to do the same.

@andresmoschini
Copy link
Author

I have accepted the contributor agreement.

@mhevery
Copy link
Contributor

mhevery commented Sep 5, 2012

It sounds to me like you have implemented reloadOnSearch feature here: http://docs.angularjs.org/api/ng.$routeProvider

I am going to close this since I think it is already implemented, If I misunderstood, please reopen.

@mhevery mhevery closed this Sep 5, 2012
@andresmoschini
Copy link
Author

Yes, it was implemented as you said, thanks.
I was a little disappointed with Angular. It seems that it is more complete and powerful that I was feeling, but it is really difficult to find this kind of things in documentation.

@CMCDragonkai
Copy link

I need this functionality for a specific link, not a specific route. Basically I need to click on a link, the link changes the URL, but does not reload the page, does not load a new state and does not load a new controller. The only thing that changes is the URL. Then I open a modal box. Is it possible to do this using reloadOnSearch? I don't think so.

@shea256
Copy link

shea256 commented Sep 16, 2013

@CMCDragonkai They do what you're talking about on this site: http://builtwith.angularjs.org/. However, I'm not exactly sure how it is implemented (I've tried messing around with their history.pushState code but it doesn't seem to give me the behavior I want).

For my app, I just ended up using search params like ?page=PAGENAME - as @mhevery says, that requires you to set the following: reloadOnSearch: false.

In the StackOverflow question below, the #1 method is to use search params.

http://stackoverflow.com/questions/12422611/angularjs-paging-with-location-path-but-no-ngview-reload/12429133#12429133

Hope this helps.

@CMCDragonkai
Copy link

Hey, I ended using ng-router, but relying on a bug to achieve what I want. Basically I cancel the stateChange event, this seems to shortcut the process, but allows the URL to be changed without anything else. They said it was actually bug. Well in this case, it's a bug that I want.

And I really want it on the paths, not query parameters, as I use query parameters for filtering the items on the page, not as page state modifiers.

@shea256
Copy link

shea256 commented Sep 16, 2013

Ah, yes, I'd actually prefer to use the paths too. So how do you cancel the stateChange event? How does it compare to this answer? http://stackoverflow.com/a/12429133/1530754

@CMCDragonkai
Copy link

I think the method on SO post will only work with search parameters, not paths. Whereas the state change cancelling will work on paths. I did notice it may not play well with the back button, but alas, no real need to use it.

Here's how I did it: angular-ui/ui-router#317 (comment)

@shea256
Copy link

shea256 commented Sep 16, 2013

Ah, interesting - I'm actually having trouble with the stateChangeStart
event. I tried binding it to $rootScope and it fires, but the fromState and
toState don't in fact have names. There also isn't any documentation for
this event. It seems that this could be a clever hack, but it might just be
worth it for me to bite the bullet and accept the search params instead of
the path change. Open to other suggestions, though.

Ryan

On Mon, Sep 16, 2013 at 3:54 PM, Roger Qiu notifications@github.com wrote:

I think the method on SO post will only work with search parameters, not
paths. Whereas the state change cancelling will work on paths. I did notice
it may not play well with the back button, but alas, no real need to use it.

Here's how I did it: angular-ui/ui-router#317 (comment)angular-ui/ui-router#317 (comment)


Reply to this email directly or view it on GitHubhttps://github.com//pull/1151#issuecomment-24539119
.

@CMCDragonkai
Copy link

As long as you have registered your states with names, all states should have names.

Here's the doc for the event: https://github.com/angular-ui/ui-router/wiki#state-change-events

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants