I have a SPA, I want to use routing for ng-view.
I have the code included in a page at domain.com/folder/dashboard.aspx
This is just a piece of that existing page, I can't move it elsewhere.
When I use route /list it alters my url to domain.com/folder/list/
which works, but breaks the ability to refresh the page (and gives a 404 since dashboard.aspx is not a default page, nor can it be)
How can I keep the url as domain.com/folder/dashboard.aspx/list
?
I did try to setup my routes as dashboard.aspx/list and other various similar adjustments, but didn't have any luck.
2 Answers
Answers 1
I figured it out.
You can't use HTML5 mode, you have to be using Hashbang.
I set my routes as normal, /list
and /list/item
For my links, I just used full urls, with the Dashboard.aspx#!/list/item
and /list
I also removed the base tag from the html page
Answers 2
Just like what @Claies said, it should be handled in your server config, just gonna drop my route config here in case you haven't tried this yet
var routeWithoutResolving = function (template: string, title?: string, style?: string) { var name; var slashIdx = template.indexOf('/'); if (slashIdx !== -1) { name = template.substring(0, slashIdx); template = template.substring(slashIdx + 1); } else { name = template; } var templateUrl = '/folder/' + template + '.aspx/'; return { templateUrl: templateUrl, title: title, style: style, area: _.capitalize(name), page: template, reloadOnSearch: false } }
Usage
.when('/domain.com/folder/dashboard.aspx/list', routeWithoutResolving ('folder/dashboard.aspx'))
0 comments:
Post a Comment