Part 2 - How to fetch data from the database using angularjs in MVC4 application.

In this post, I would like to explain Part 2 - How to fetch data from the database using angularjs in MVC4 application.

This is our second Post about AngularJS. Here I have explained a little about AngularJS and What we will learn in this section part by part. 

In Part1 of this post we configured AngularJS in MVC4 application. In this part (Part 2) I am going to explain how to fetch data from the database using angularjs in MVC4 application.

Here In this example I will use AngularJS $http service. $http is an AngularJS service for reading data from remote servers.

Contact Details
First Name : {{Contact.FirstName}}
Last Name : {{Contact.LastName}}
Contact No1: {{Contact.ContactNo1}}
Contact No2: {{Contact.ContactNo2}}
Email ID: {{Contact.EmailID}}
Address {{Contact.Address}}
Part 2 - How to fetch data from the database using angularjs in MVC4 application.
<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8" />
    <meta name="viewport" content="width=device-width" />
    <title>@ViewBag.Title</title>
    @Styles.Render("~/Content/css")
    @Scripts.Render("~/bundles/modernizr")
</head>
    @* Here  ng-app="MyApp" is used for auto-bootstrap an AngularJS application. here ng-app="MyApp" means <body> element is the owner 
    of AngularJS application*@
<body ng-app="MyApp">
    @RenderBody()

    @Scripts.Render("~/bundles/jquery")
    @* Add Angular Library Here *@
    @Scripts.Render("~/bundles/angular")
    <script src="~/Scripts/MyApp.js"></script>
    @RenderSection("scripts", required: false)
</body>
</html>


 
Posted By :