IN This Tutorial you will learn how to build a single page Address Book App with angularjs

Here is the preview of our app

Styling the app

so , Let’s start by creating our models in a controller called PeopleController. We’ll now write all our JavaScripts in a file called scripts.js. Your scripts.js file should look like this:

function PeopleController($scope){
   {name:"John Doe", phone: "3452345678", city:"New York"},
   {name:"Sarah Parker", phone: "1236548769", city:"Chicago"},
   {name:"Little John", phone: "4567853432", city:"Los Angeles"},
   {name:"Adam Doe", phone: "9025673152", city:"Las Vegas"}

Here we are defining the controller called PeopleController and creating our model called people. The model contains three attributes: name, phone, and city.

Now, let us get our markup in place. Let us call the file index.html using the following code:

<!DOCTYPE html>
<html ng-app>
         <title>Address Book</title>
   <body ng-controller="PeopleController">
   <h1>Address Book</h1>	
         <div ng-repeat="person in people">
                <div>{{}} - {{}}</div>
                <span>{{}} </span>


   <script src= "angular.min.js" type="text/javascript"></script>
   <script src= "scripts.js" type="text/javascript"></script>


It is always a good practice to load your JS files at the end of the page just above the body tag and not in the head. You can read more about why this matters here at

As you can see here, we are defining the HTML5 doctype in the first line, and then we initialize the angularjs application by using the ng-app directive. You’ll also notice that we are using the ng-controller directive and assigning PeopleController to it. By doing so, we are defining the section of the DOM that is now within the scope of this controller.

You’ll also notice a new directive called ng-repeat; this is the built-in directive used to display a list of items from a collection. The ng-repeat directive would simply duplicate the DOM element and bind the defined properties of the data object.

As you can see, ng-repeat makes it so easy and clean to display record sets as compared to doing this in jQuery or plain vanilla JavaScript.

Now, run your index.html in the browser and you should be seeing the names with their phone numbers and cities being displayed. The data from our model is showing up, which is good. Let us also inspect the code to have a look at the changes angularjs is making to our markup.