V
V
Vladimir Kuts2017-04-01 09:21:01
Angular
Vladimir Kuts, 2017-04-01 09:21:01

How to pass parameters to url in angularjs?

Angularjs 1.6.4
Trying to pass parameters to url:

window.location.replace('/some/url/'+some.id+'/?queryfield=field100')

On the page after the redirect
var absUrl = $location.absUrl();
> somesite.ex/some/url/596/?queryfield=field100 >
var searchObject = $location.search();
Object {}
window.location.replace('/some/url/'+some.id+'/#?queryfield=field100')

What was needed arrived in $location.search().
Now the url looks like this
http://somesite.ex/some/url/596/#!#%3Fqueryfield=f...
and $location.search() still throws an empty object
Why is searchObject empty? How to get parameters besides parsing url with regular expression?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
V
Vladimir Kuts, 2017-04-01
@fox_12

The problem was solved like this:

app.config(['$locationProvider', function($locationProvider) {
  $locationProvider.hashPrefix('');
}]);

N
Nicholas, 2017-04-01
@healqq

Is there any reason why you are not using a router?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question