javascript - How to get value of REST style parameter in Angular? -


i have application in asp.net mvc. use rest-style parameters. address of 1 action http://app/resource/action/id.

in angular can access query strings using $location.search() or $routeparams.search or $window.location.search. though of these methods can obtain query string parameters.

how can access id parameter (without splitting window.location.pathname)?

in route configuration can this:

$routeprovider. when('/:resource/:action/:id', { templateurl: 'partials/your-partial.html', controller: 'yourctrl' })

you can use $routeparams access properties require follows:

var resource = $routeparams.resource; var action = $routeparams.action; var id = $routeparams.id;


Comments

Popular posts from this blog

javascript - jQuery: Add class depending on URL in the best way -

caching - How to check if a url path exists in the service worker cache -

Redirect to a HTTPS version using .htaccess -