user2818430
user2818430

Reputation: 6029

How can I use Angular 2 on top of my MVC app?

With AngularJS I could define my app in the body like this:

<body ng-app="myapp">

Then I could load different controllers in different views within my MVC app.

Let's say in Home/Index view I load one controller, and in Home/About I can load a different one which do a different logic.

I am trying to understand Angular 2, and I have a feeling that all you can do with it is a SPA? Are you kidding me? If I don't want to build a SPA, basically I have to duplicate my code, and create Angular app again and again for each view. Is this true that you have to build only SPAs?

How can I use Angular 2 on top of my MVC app, using all MVC functionalities like routing, etc.?

Upvotes: 3

Views: 1215

Answers (1)

Roman C
Roman C

Reputation: 1

Feel like you have a whole application in one page returned by your MVC controller, and this page requires it's own api. However you can route to MVC framework back with any link. You don't have to use Angular router for it. The cost of switching between angular and non-angular worlds is very high. May be in the future releases of angular it will be cheaper. Anyway the concept of Multipage application is raw at the moment, and server-side rendering is not yet supported by the framework. It should come in the future versions.

Resources:

Upvotes: 2

Related Questions