Part 1 - Simple Contact Book application in angularjs

Before this article, we have done many examples using AngularJS like, fetch & dispaly data from databasecreate simple registration form with validationImplement AngularJS routing any much more. But  till now we have not created any complete application. Today I will show you how to create a very simple application using AngularJS in asp.net MVC.


Here in this part, I will try to make our application as simple as possible and later we will enhance this application part by part for making the article easy to understand.

Part 1 - Simple Contact Book application in angularjs
<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>@ViewBag.Title - My ASP.NET Application</title>
    @Styles.Render("~/Content/css")
    @Scripts.Render("~/bundles/modernizr")

</head>
<body ng-app="myContactBook">
    <div class="navbar navbar-inverse navbar-fixed-top">
        <div class="container">
            <div class="navbar-header">
                <button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".navbar-collapse">
                    <span class="icon-bar"></span>
                    <span class="icon-bar"></span>
                    <span class="icon-bar"></span>
                </button>
                @Html.ActionLink("Application name", "Index", "Home", null, new { @class = "navbar-brand" })
            </div>
            <div class="navbar-collapse collapse">
                <ul class="nav navbar-nav">
                    <li><a href="#/home">Home</a></li>
                    <li><a href="#/savecontact/0">Add Contact</a></li>
                </ul>

            </div>
        </div>
    </div>
    <div class="container body-content">
        @RenderBody()
        <ng-view></ng-view>
        <hr />
        <footer>
            <p>&copy; @DateTime.Now.Year - My ASP.NET Application</p>
        </footer>
    </div>

    @Scripts.Render("~/bundles/jquery")
    @Scripts.Render("~/bundles/bootstrap")
    @RenderSection("scripts", required: false)
    <script src="~/Scripts/angular.js"></script>
    <script src="~/Scripts/angular-route.js"></script>
    <script src="~/Scripts/ngComponents/ngConfigs/main.js"></script>
    <script src="~/Scripts/ngComponents/ngControllers/homeController.js"></script>
    <script src="~/Scripts/ngComponents/ngControllers/saveContactController.js"></script>
    <script src="~/Scripts/ngComponents/ngControllers/errorController.js"></script>
    <script src="~/Scripts/ngComponents/ngServices/contactService.js"></script>
    <style>
        .error{
            color:red;

        }
    </style>
</body>
</html>

Posted By :