Using `history.replace` with Angular 1.x

I need help with help history.replaceState

in an Angular 1.x app.

My chrome extension is interacting with some elses app, and I want to load a Url in that app with an additional query parameter that my extension can extend and then use history.replaceState

to remove from the url.

  • Step 1: open www.otherapp.com?extensionToken=MhtkWGUyS#/settings

  • Step 2: read xtensionToken=MhtkWGUyS

  • Step 3: replace / remove token from replaceState

    beforewww.otherapp.com#/settings

The problem is Angular 1.x can't use history.replaceState on its own: https://github.com/angular/angular.js/issues/3789 p>

Angular seems to be reversing my update back to the original url, or cross-url altogether. Anyone have any experience history.replaceState

with an Angular app?

One solution I was thinking about was using Angular s $location

to change state, but I don't know how to access $location

outside of Angular scope. Does anyone know how I can access this?

The tricky part of generating a link to $location

is that my code will work with many different applications with their own unique Angular elements ng-

, and I don't know what those elements are on the page. I can assume most of them have Angular in window.angular

, but I cannot easily assume that there will be an Angular app element for every page.

+3
angularjs html5-history angular-routing angularjs-ng-route


source to share


No one has answered this question yet

Check out similar questions:

1006
What is the difference between angular-route and angular-ui-router?
432
Angular directives - when and how to use compilation, controller, pre-link and post-link
402
Angular ng-repeat Error "No duplicates allowed in a relay."
357
angular login authentication ui-router
6
Safari Extension - Update angularJS model by form autocomplete
five
Alternative to using hashbangs in url to solve IE9 problem
4
Why do some html elements need Angular.JS directives and others don't?
1
In AngularJS, how do I keep track of the observer for a view and automatically remove them when the view is removed or replaced?
0
Angular not suitable for Laravel API (ports issues)
0
Routing in Angular 7 works in a subfolder not working correctly



All Articles
Loading...
X
Show
Funny
Dev
Pics