0

I have a symphony built, in which I have a page working with Angularjs 1.5.*.

I'm not using the angularjs route so I don't have the variables there.

My url is (and might change where the 16 is, though always at the end of url):

www.mydomain.com/billing/detail/16

I want to get the 16 from the url.

Just want to get that number and handle it in my controller so I can call a symphony controller and get the data I currently have hardcoded.

Thanks !!!!

3
  • will the url always be "www.mydomain.com/billing/detail/??" Commented Dec 20, 2016 at 19:16
  • 2
    Possible duplicate of How to parse a URL? Commented Dec 20, 2016 at 19:19
  • Yes. It's going to be like that. Thanks Commented Dec 20, 2016 at 19:29

5 Answers 5

2

You can use window.location object.

location.pathname.split("/").pop()
Sign up to request clarification or add additional context in comments.

1 Comment

Thanks. That did the work. I was trying to use angular and wasn't necessary.
0

If you do not want to use $routeParams, you could try to get the url using

$location.absUrl();

and then parse it to get the value you need.

Comments

0

you should use $stateParams. like $somevar = $stateParams.urlParamName;

Comments

0

You can extract the Url into a string using like below:

var url = new URI('www.mydomain.com/billing/detail/16'); 

url.path(); which will return '/billing/detail/

Then you can just use split like this:

var url = "www.mydomain.com/billing/detail/16";

$scope.myvalue = getUrlID(url);

function getUrlID(str) {
    return str.split('www.mydomain.com/billing/detail/')[1];
}

Here is a Plunker. Of course it is hardcoded in the plunker because I can't access your URL, but this should get you going.

2 Comments

Thanks for taking your time. Found the solution with javascript.
No problem. Glad you figured it out.
0
$location.absUrl().split("/").pop()

1 Comment

Should have been a comment! If you don't have enough score to add comments, add more details to support your answer. Flagged in reviews

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.