Click here to Skip to main content
15,905,508 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I am working on a MVC5 application.
I have to apply Angular routing to it and am able to apply that.
But on any postback the application goes back to the MVC routing again.
Please suggest how to stop MVC routing when we intend to use angular routing in a MVC application?

For ex : I have a set of scaffold pages for a table to perform CRUD operations.
To apply Angular routing it seems the Layout of the views to be made null.
So on a save button click in Create or Edit, the data gets saved but because of its postback, the routing changes from angular to mvc and the page gets displayed with out a layout which means it is going to mvc routing.
Please suggest.
Posted
Updated 12-Nov-15 17:40pm
v2

We had the same issue here and had to use the html5Mode to turn it off and use hash routing instead. This seems to solve our issue with the MVC and Angular routing

JavaScript
$location.html5Mode ( false ) ; 
 
Share this answer
 
Comments
goshan2011 13-Nov-15 0:26am    
If # routing is used then @html.Actionlink wont work which is there in all scafold pages.
onelopez 13-Nov-15 0:59am    
can't use the actionlink when using angular's routing. you have to use angular's routing mechanism to change the ui
Remove the routes set in the Global.asax file.

However, this should not be required. Both routing from angular and mvc can exist together.
Its how and where you call views (angular and MVC) that will matter.
 
Share this answer
 
Comments
goshan2011 13-Nov-15 0:32am    
The routing from both can exist together but the problem is as i mentioned in the example i.e in the Create view of the scafold templates for crud operations for a table, the layout has to be made null to activate angular routing. On Save button click in the Create view, data gets inserted in the db but on this action, page postback happens and the angular routing is lost and because the layout is made null for the Create view..the page looks in the browser with out layout and goes to mvc routing...am i missing any thing here.... i just started learning a mix of mvc and angular js ...pls suggest the fundamentals even if i miss...

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900