0

I want to have on the URL of my application like this:

http://localhost:9000/#/?id=XYZ

I don't found how to configure this on angularjs app module My implementation is like that:

angular.module('APP', ['ngRoute'])
.config(function ($routeProvider) {
  $routeProvider.when("/?id="+":id", {
    templateUrl: "views/sign/sign.html",
    controller: "SignCtrl"
  });
  // $locationProvider.html5Mode(true);
});

but It doesn't work.

2 Answers 2

1

You do not have to specify

it will be like

angular.module('APP', ['ngRoute'])
.config(function ($routeProvider) {
  $routeProvider.when("/", {
    templateUrl: "views/sign/sign.html",
    controller: "SignCtrl"
  });
  // $locationProvider.html5Mode(true);
});

and in your SingCtrl.

when you write $routeParam than you will have objects of params which are passed as a query parameter.

so you will get $routePara.id if you pass like ?id=anything

Do not have to worry if you want to catch the query param like ?id=abs&name=test

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

Comments

0

You can add a "url" attribute to your $routeProvider object.

Something like:

$routeProvider.when("/?id="+":id", {
templateUrl: "views/sign/sign.html",
url: 'the Url you want to use',
controller: "SignCtrl"
});

PS.: I suggest you to use ui-router instead of ngRoute. Check it out later.

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.