Then I c...">

Angular 2 - ASP.NET MVC Application - NO SPA

With Angular 1, I could define my application in the body like this: <body ng-app="myapp">Then I could load different controllers into different views in my MVC application.

Say, in the Home / Index view, I load one controller, and Home / About I could load another and make another logic.

I'm trying to understand Angular 2, and I have the feeling that all you can do with it is SPA? Are you kidding me? If I do not want to create a SPA, I have to duplicate my code and create an Angular application again and again for each view. Is it true that you only need to build a SPA?

How can I use Angular 2 on top of my MVC application using all the MVC features like routing, etc.?

+4
source share
1 answer

Feel that you have an entire application on one page returned by your MVC controller, and this page requires its own api. However, you can redirect to the MVC infrastructure with any link. You do not need to use an Angular router for this. The cost of switching between Angular and non-angular worlds is very high. Perhaps in future releases of Angular it will be cheaper. In any case, the concept of the Multipage application is the source at the moment, and server-side rendering is not yet supported by the framework. It should appear in future versions.

Resources:

+2

Source: https://habr.com/ru/post/1671509/


All Articles