0

If this is my route setup, I'd like the "otherwise" route to redirect to '/inbound?page=0&size=20&sort=number,desc" but the "?" in the route is escaped to "%3F".

  .config(function ($routeProvider) {
    $routeProvider
      .when('/outbound', {
        templateUrl: 'views/shipments.html',
        controller: 'ShipmentCtrl'
      })
      .when('/inbound', {
        templateUrl: 'views/receipts.html',
        controller: 'ReceiptsCtrl'
      })
      .otherwise({
        redirectTo: '/inbound'
      });
  });

2 Answers 2

1

continuing the previous answer, you should just set the default values in your inbounds route controller something like

var search=$location.search();
var page=search.page||0;
var size=search.size||20;
var sort=search.sort||'number,desc';

the exact way of doing it would depend on how permissive are you with the empty strings and the 0 size requests but thats kinda the idea

Sign up to request clarification or add additional context in comments.

1 Comment

This was indeed the way to go :) Thank you.
0

You can use $location.search() in the starting line of controller. It will add get parameter to the url.

https://docs.angularjs.org/api/ng/service/$location

Comments

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.