How to load HTML page in MVC 5 for Angularjs routing?

▼魔方 西西 提交于 2020-02-08 09:51:08

问题


I want to use the SPA concept of angularjs in MVC 5, but cant handle the routing. I want my main page to view in Razor and load portion of the page using angularjs. I know my description is not sufficient but hope anyone will help me through. Thanks in advance.


回答1:


Look at the project template AngularStart

https://visualstudiogallery.msdn.microsoft.com/cc6c9c5f-2846-4822-899f-a6c295cd4f2b

I am author of this template and it shows how can client side routing and mvc routing can be combined. This has been created for MVC 4, but you will get an idea.

I also created a blog post http://blog.technovert.com/2013/12/setting-up-angularjs-for-asp-net-mvc-n-webapi-project/ explaining the approach.




回答2:


You may run into conflict if routing is setup both for MVC 5 and Angular. For SPA portion use only Angular routing. That being said you can still have a hybrid solution for partials where angular templates are assembled by Razor templates (which is a very powerful feature).



来源:https://stackoverflow.com/questions/29813897/how-to-load-html-page-in-mvc-5-for-angularjs-routing

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!