0

Is there a way to pass data to controller without including a question mark ?

For example :

When i do this :

$location.path("/inventory/product").search({                       
  id: 1
});

The end url looks like localhost:16684/#/inventory/product?id=8. How can i make it so that it looks like localhost:16684/#/inventory/product/8 ?

Here is my route config :

{
  url: '/inventory/product',
  controller: 'inventory',
  config: {
    title: 'Products',
    templateUrl: 'app/views/inventory.html'
  }
},

Thanks!

1
  • If you want to share data between controllers you can use $rootScope instead of $scope. Commented Sep 17, 2014 at 9:30

1 Answer 1

1

Write it like this :

$location.path("/inventory/product/"+id)

add a second route, and make it go to the same controller

{
  url: '/inventory/product',
  controller: 'inventory',
  config: {
    title: 'Products',
    templateUrl: 'app/views/inventory.html'
  }
},
{
  url: '/inventory/product/:id',
  controller: 'inventory',
  config: {
    title: 'Products',
    templateUrl: 'app/views/inventory.html'
  }
},
Sign up to request clarification or add additional context in comments.

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.