1

i'm developing a front-end like pinterest, when the pin is clicked this should be loading in a modal, no problem here.

but a requirement is that, the URL should change when the modal is loaded and in the background must keep pins list.

I can't do it, tried using angular-ui, but when the URL change the ui-view elements are cleaned too

Here in stackoverflow are many similar questions, but the problem here is that not children URLs

url1: site.com / list / categorie -> url2: site.com / title

How I can change the URL and keep the current contents in the background?

thanks!

Luis Cruz
  • 159
  • 1
  • 11

3 Answers3

1

After few days i got it, this code must be in the controller

var lastRoute = $route.current;
    $scope.$on('$locationChangeSuccess', function(event) {
        if($route.current.$$route.controller == 'modal'){
            $route.current = lastRoute;
        }
    });

this will keep the current ngview HTML, but change the url

I found the solution here https://stackoverflow.com/a/12429133/1179213

Community
  • 1
  • 1
Luis Cruz
  • 159
  • 1
  • 11
0

You can most likely use HTML history's API. Check out this post. Updating address bar with new URL without hash or reloading the page

Since you are doing this outside of Angular, it should not affect anything but the URL.

Hope that works!

Community
  • 1
  • 1
Faisal Abid
  • 8,900
  • 14
  • 59
  • 91
  • Thanks!, i tried this and not work, i use history.pushState({}, "page 2", "test.html"); angular take a infinite loop, maybe trying to redirect http://snag.gy/dkJ8e.jpg – Luis Cruz Dec 12 '13 at 21:22
  • I was implement the code in a loop, my mistake, I will try to implement it in a better way, hope it works, thanks – Luis Cruz Dec 12 '13 at 21:36
  • I fail to make it work with pushState, is very unstable – Luis Cruz Dec 13 '13 at 03:39
0

You can use a query parameter to highlight the correct image using $location.search and $watch-ers.

musically_ut
  • 34,028
  • 8
  • 94
  • 106
  • thanks, but this only adds a query string to the end of the url, and the first url is not parent of the second, i think not work in this case – Luis Cruz Dec 12 '13 at 21:28