Thursday, 9 October 2014

angularjs dynamic links and $locationProvider.html5Mode(true);


 with $locationProvider.html5Mode(true);
 then you should make the links like this : href='/xxxx'
 and in the route.js you should have the templateurl like this: templateUrl: '/views/monday.html', the root slash is important.

 without $locationProvider.html5Mode(true);
 then you should make the links like this : href='#/xxxx'

Because with $locationProvider.html5Mode(true);

All redirect is based on the current url.
So, if the route.js is:
                        id: 'monday',
                        url: '/monday/:xx',
                        templateUrl: 'views/monday.html',
                        controller: 'MondayCtrl'
then the an accessing to will be redirected to: 

So in this case, all links should be in abstract form.

Note: window.location.href = "/monday/abc", this different. this code is used to change the url of your browser.

No comments:

Post a comment