Reputation: 1461
I am hitting a REST endpoint at
www.example.com/resource/id
What is the best way for me to extract id from an angular module controller? I have looked into using $routeProvider
$routeProvider.when('/resource/:id', {}).otherwise(...)
This will only work if I set
$locationProvider.html5mode(true)
If it is not set to true, it always ends up in the otherwise clause when I hit www.example.com/resource/8
How can I get this to work even if I don't set $locationProvider.html5mode to true?
Upvotes: 0
Views: 66
Reputation: 23211
just replace following code:
$routeProvider.when('/resource/:id', {}).otherwise(...)
with the:
$routeProvider.when('resource/:id', {}).otherwise(...)
/resource/:id
ths take absolute url pattern. and resource/:id
take relative url pattern.
so i think this will help you without setting of html mode true.
Upvotes: 0
Reputation: 21901
use www.example.com#/resource/8
instead www.example.com/resource/8
Upvotes: 0