AngularJS routing in MVC application with templates

后端 未结 1 1989
渐次进展
渐次进展 2021-01-14 07:24

I have 3 MVC controllers :

  • Dashboard (the one by default)
  • Customer
  • Employee For each, only the \"Index\" action is available with only the \"
相关标签:
1条回答
  • 2021-01-14 07:59

    AngularJS loads the page once, then only loads the missing data from the server (as JSON data). MVC loads the complete page on every request.

    Based on this, you can't use the same routing for you MVC and AngularJS application, you have to decide for one of the concepts.

    This means you either us angular for advanced client UI features (like filtering) and make the routing entirely on the server, or you deliver only a single MVC page and provide interface for accessing your date(e.g. as described here: https://stackoverflow.com/a/16837181/639035).

    Using the same routing for AngularJS and MVC would mean you have to implement a Controller which returns the views (complete HTML pages), and a controller which provides the JSON data for the AngularJS routing. This results in a lot of work, is not easy to maintain and as far as I see it doesn't provide any advantages.

    MVC Page concept (traditionell conecpt) Das klassische Web-Paradigma Anglular Page concept (or Single Page Application (SPA) concept) Single Page Application (SPA) Framework

    0 讨论(0)
提交回复
热议问题