Tuesday, 12 July 2016

Angular: Redirecting to another location with query strings

There are a couple of ways to redirect to a new location:

window.location.href / $window.location.href

However, when using routing ($routeProvider), $location is the way to go.

To navigate to another route:


To navigate to another route using query strings (such as ?k=test)

$location.path("/Search").search('k', 'test');

To extract the query values, use