当前位置: 动力学知识库 > 问答 > 编程问答 >

javascript - Angular hashtag changing file path

问题描述:

I'm trying to create 2 separate applications within one site using AngularJS, and I'm trying to figure out how the RouteConfig interacts with the hashtag angular adds to the url.

Basically,

I enter [sitename]/App1

and this is changed to [sitename]/App1#/ by angular, and everything works fine.

However if I enter [sitename]/App1/ this is changed to [sitename]/App1/#/ and everything breaks because it starts looking for html files under http://[sitename]/App1/Views/Angular/[file.html] instead of http://[sitename]/Views/Angular/[file.html] where they are located.

Why does this happen? Why does that extra slash added in there cause angular to change the path it looks for files?

Edit: Routing is as follows,

routes.MapRoute(

name: "Default",

url: "{controller}/{action}/{id}",

defaults: new { controller = "home", action = "Index", id = UrlParameter.Optional }

);

分享给朋友:
您可能感兴趣的文章:
随机阅读: