(This article also published in my public number "dotnet daily Essence article", Welcome to the right QR code to pay attention to. )
Angularjs as an increasingly popular front-end framework, when developing Web applications using ASP. NET MVC and the Entity Framework, it makes it easier to develop your front-end interface with proper use. Today's recommended article is about how to incorporate ANGULARJS into ASP. NET MVC development.
Although the previously developed SaaS system is based on ASP. NET MVC, Entity Framework, the front end is supplemented with ANGULARJS. But it's been a long time. Summing up this experience to share with you, just the article recommended today is about how to integrate Angularjs into the Web application development of ASP. In fact, the steps are simple:
- Add AngularJS to ASP. NET MVC Web project via NuGet (I usually use the author's package for the AngularJS team)
- Reference the Angularjs JS file in the view or layout file, or you can add it to the bundles
- Get data through the Entity Framework
- Returning JSON data in the controller of the ASP. NET Mvc/web API
- Consume the JSON data returned by these services in the ANGULARJS service
- Call the Angularjs service in the ANGULARJS controller to pass the data to the view
- Rendering data in the Angularjs view
Dhananjay KUMAR This article is basically to follow this step of a complete introductory exercise, through the "read the original" to carefully read the text, mapping and code, to get started is not difficult.
Of course, in practice there are some skills, but also need to find a way to suit their own situation. For example, we did not make the entire Web application a single page application based on ANGULARJS, but simply optimized the front-end code with ANGULARJS's binding, MVC model, on pages that require highly interactive application,spa. In particular, Ng-app is generally based on an ASP. NET MVC view, and these views take full advantage of the features of the ASP itself (such as layout to unify layouts, use of the Partialview combination interface, etc.). We will be free to analyze our experience in detail later.
Original address: http://www.infragistics.com/community/blogs/dhananjay_kumar/archive/2015/05/13/ How-to-use-angularjs-in-asp-net-mvc-and-entity-framework-4.aspx
How to use ANGULARJS in ASP. NET MVC and EF