Improve this doc

You are now ready to build the AngularJS phonecat app. In this step, you will become familiar with the most important source code files, learn how to start the development servers bundled with angular-seed, and run the application in the browser.

In angular-phonecat directory, run this command:

git checkout -f step-0

This resets your workspace to step 0 of the tutorial app.

You must repeat this for every future step in the tutorial and change the number to the number of the step you are on. This will cause any changes you made within your working directory to be lost.

If you haven't already done so you need to install the dependencies by running:

npm install

To see the app running in a browser, open a separate terminal/command line tab or window, then run npm start to start the web server. Now, open a browser window for the app and navigate to http://localhost:8000/app/index.html

You can now see the page in your browser. It's not very exciting, but that's OK.

The HTML page that displays "Nothing here yet!" was constructed with the HTML code shown below. The code contains some key Angular elements that we will need as we progress.

app/index.html:

<!doctype html>
<html lang="en" ng-app>
<head>
  <meta charset="utf-8">
  <title>My HTML File</title>
  <link rel="stylesheet" href="bower_components/bootstrap/dist/css/bootstrap.css">
  <link rel="stylesheet" href="css/app.css">
  <script src="bower_components/angular/angular.js"></script>
</head>
<body>

  <p>Nothing here {{'yet' + '!'}}</p>

</body>
</html>

What is the code doing?

Bootstrapping AngularJS apps

Bootstrapping AngularJS apps automatically using the ngApp directive is very easy and suitable for most cases. In advanced cases, such as when using script loaders, you can use imperative / manual way to bootstrap the app.

There are 3 important things that happen during the app bootstrap:

  1. The injector that will be used for dependency injection is created.

  2. The injector will then create the root scope that will become the context for the model of our application.

  3. Angular will then "compile" the DOM starting at the ngApp root element, processing any directives and bindings found along the way.

Once an application is bootstrapped, it will then wait for incoming browser events (such as mouse click, key press or incoming HTTP response) that might change the model. Once such an event occurs, Angular detects if it caused any model changes and if changes are found, Angular will reflect them in the view by updating all of the affected bindings.

The structure of our application is currently very simple. The template contains just one directive and one static binding, and our model is empty. That will soon change!

What are all these files in my working directory?

Most of the files in your working directory come from the angular-seed project which is typically used to bootstrap new Angular projects. The seed project is pre-configured to install the angular framework (via bower into the app/bower_components/ folder) and tools for developing a typical web app (via npm).

For the purposes of this tutorial, we modified the angular-seed with the following changes:

Experiments

Summary

Now let's go to step 1 and add some content to the web app.