0

How to get id value using angularjs from this path:

http://localhost:1234/?id=3333#/Plya/Home 

Any idea how can I do it?

2 Answers 2

1

You can use $location.search() followed by your parameter you want to get:

var paramValue = $location.search().id;

This will only work however if you have set html5mode to true in your config like so:

angular.module("myApp", []).config(function($locationProvider) { 
  $locationProvider.html5Mode(true); 
});
Sign up to request clarification or add additional context in comments.

1 Comment

Completely forgot about that (Guess I am used to having HTML5 mode enabled :)). In non-HTML5 mode $location.search() only returns params after the hashtag. Upvoted your answer
0

Inject $location into your controller

and then you can use

$location.search().id

e.g.

$scope.id = $location.search().id

HTML5 should be enabled for this to work in your case (thanks Chrillewoodz)

In non-HTML5 mode $location.search() only returns params after the hashtag

3 Comments

do i have to parse the value?
it;s return me value true
Check the answer of Chrillewoodz

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.