angularjs - how to implement custom routes in angular.js? -


i've got route:

.state('home.blog', {   url: "/blog",   templateurl: "blog.html",   controller: "blogcontroller" }) 

and route localhost:3000/home/blog change localhost:3000/blog. searched internet have not found simple solution.

this because url part dervied parent. can explicitly set, parent should not used '^':

.state('home.blog', {   url: "^/blog",   templateurl: "blog.html",   controller: "blogcontroller" }) 

see doc

absolute routes (^)

if want have absolute url matching, need prefix url string special symbol '^'.

$stateprovider   .state('contacts', {      url: '/contacts',      ...   })   .state('contacts.list', {      url: '^/list',      ...   }); 

Comments