0

For page navigation in asp.net MVC application with Angular.js, shall we use only angular.js routing or go to server for new page using asp.net MVC controller.

psb
  • 55
  • 7

2 Answers2

0

I personally like to just use MVC to serve the default AngularJS files and then let Angular's routing handle the navigation within the application.

Andy T
  • 10,223
  • 5
  • 53
  • 95
0

It depends on how you have designed the application architecture and communication. Primarily, if you are using the ViewResult result type from the Action methods then you will have to use the MVC routes. Understand that angularjs $routeProvider enables client side routing only and is not the same as MVC (server side) routes.

You use the $location object to capture the URL changes to the address bar and the request is captured by the angular route (before it gets a chance to fire towards the server) and the configured template and controller are served.

Hope you understand that you then would (generally) use the $http service to fire asynchronous calls to the respective actions on the server that WILL make use of the MVC defined routes too.

Logically, group related sections of your application using template-type routing on the angular side and more generalized routes on the server side.

Check out the mechanics in another post here.

Hence, like I said, it really depends on your design.

Community
  • 1
  • 1
Vaibhav
  • 2,527
  • 1
  • 27
  • 31