question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

$state.href() does not include path

See original GitHub issue

My Angular app resides at a path on my server, /app, not the root / path. Calling $state.href does not seem to include the path name in its return value.

Example:

$state.href("doggy", { style: "raw" }, { absolute: true });

Results in:

http://localhost:8080/#/doggy?style=raw 

Whereas really it should be:

http://localhost:8080/app/#/doggy?style=raw 

Am I missing something obvious here or is this a bug?

Issue Analytics

  • State:closed
  • Created 9 years ago
  • Comments:10 (3 by maintainers)

github_iconTop GitHub Comments

3reactions
mscheringcommented, May 2, 2017

I’ve worked around with this:

var aboluteUrl = document.location.origin + document.location.pathname + $state.href(‘mystate’) ;

0reactions
spahichariscommented, Mar 27, 2017

Try changing absolute: true to absolute: false. This worked for me.

Read more comments on GitHub >

github_iconTop Results From Across the Web

AngularJS UI-Router : Get the absolute URL of the state with ...
To get the absolute URL you can then use: $state.href('user.home.view', {}, {absolute: true}); · To get the URL with the parameters in place...
Read more >
Directives - UI-Router
A directive which links to a state (and optionally, parameters). When clicked, this directive activates the linked state with the supplied parameter values....
Read more >
How can we specify no route path in UI-Router - Edureka
I'm having web page that contains all the links, but the problem is if the user attend to follow the unspecified path, How...
Read more >
Easier AngularJS Routing with Angular UI Router
Does not allow you to pass around data during navigation. ... Notice that the element is updated to include an href attribute with...
Read more >
Developer Guide: Using $location - AngularJS: API
All values that are passed to $location setter methods, path() , search() , hash() ... AngularJS also does not intercept and rewrite links...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found