You are now ready to build the Angular phonecat application. 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.
./scripts/web-server.js
to start the web server.angular-phonecat
directory.http://localhost:[port-number]/[context-path]/app/index.html
.Open msysGit bash and run this command (in angular-phonecat directory):
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.
node
scripts\web-server.js
to start the web server.angular-phonecat
directory.http://localhost:[port-number]/[context-path]/app/index.html
.In the angular-phonecat directory, run this command:
./goto_step.sh 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.
./scripts/web-server.js
to start the web server.sandbox
directory.http://localhost:[port-number]/[context-path]/app/index.html
.Open windows command line and run this command (in the angular-phonecat directory):
goto_step.bat 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.
node
scripts\web-server.js
to start the web server.sandbox
directory.http://localhost:[port-number]/[context-path]/app/index.html
.You can now see the page in your browser. It's not very exciting, but that's OK.
The static 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 going forward.
app/index.html
:
<!doctype html> <html xmlns:ng="http://angularjs.org/"> <head> <meta charset="utf-8"> <title>my angular app</title> <link rel="stylesheet" href="css/app.css"/> </head> <body> Nothing here yet! <script src="lib/angular/angular.js" ng:autobind></script> </body> </html>
xmlns declaration
<html xmlns:ng="http://angularjs.org">
This xmlns
declaration for the ng
namespace must be specified in all Angular applications in
order to make Angular work with XHTML and IE versions older than 9 (regardless of whether you are
using XHTML or HTML).
Angular script tag
<script src="lib/angular/angular.js" ng:autobind>
This single line of code is all that is needed to bootstrap an angular application.
The code downloads the angular.js
script and registers a callback that will be executed by the
browser when the containing HTML page is fully downloaded. When the callback is executed, Angular
looks for the ng:autobind
attribute. If Angular finds
ng:autobind
, it creates a root scope for the application and associates it with the <html>
element of the template:
As you will see shortly, everything in Angular is evaluated within a scope. We'll learn more about this in the next steps.
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 includes the latest Angular libraries, test libraries, scripts and a simple example app, all pre-configured for developing a typical web app.
For the purposes of this tutorial, we modified the angular-seed with the following changes:
app/img/phones
app/phones
Now let's go to step 1 and add some content to the web app.