This application takes the developer through the process of building a web-application using angular. The application is loosely based on the Google Phone Gallery, which no longer exists. Here is a historical reference: Google Phone Gallery on WayBack.
Each tagged commit is a separate lesson teaching a single aspect of angular.
The full tutorial can be found at http://docs.angularjs.org/tutorial.
npm install
)You can check out any point of the tutorial using git checkout step-?
To see the changes which between any two lessons use the git diff command. git diff step-?..step-?
PhoneListCtrl
controller for the applicationngRepeat
directive which iterates over the dataset of phones.
ngRepeat
clones its contents for each instance in the dataset and renders it into the view.filter
filter.ngRepeat
automatically shrinks and grows the number of phones in the view.age
property to each phone in the data model.<select>
input to change the phone list order.phones.json
file).
phones.json
file is loaded using the $http
service.Introduce the $route service which allows binding URLs for deep-linking with views:
PhoneCatCtrl
which governs the entire app and contains $route configuration.angular-route
using bower and load the ngRoute
module.
(Be sure to run npm install again.)params
property for access in sub controllers.index.html
with the ngView
directive, which will display the partial
template of the current route.Create phone list route:
/phones
route to PhoneListCtrl
and partails/phones-list.html
.PhoneListCtrl
controller.index.html
to partials/phone-list.html
.Create phone details route:
/phones/<phone-id>
route to PhoneDetailCtrl
and partails/phones-detail.html
.PhoneDetailsCtrl
controller.PhoneDetailCtrl
controller to fetch the details for a specific phone from a JSON file
using $http
service.checkmark
filter.checkmark
filter.In the phone detail view, clicking on a thumbnail image, changes the main phone image to be the large version of the thumbnail image.
mainImageUrl
model variable in the PhoneDetailCtrl
and set its default value.setImage()
controller method to change mainImageUrl
.ngClick
directive on thumb images to set the main image, using
setImage()
.Phone
service that represents the $resource
client.The following docs describe how you can test and develop further this application.
The application relies upon various node.js tools, such as Bower, Karma and Protractor. You can install these by running:
npm install
This will also run bower, which will download the angular files needed for the current step of the tutorial.
Most of the scripts described below will run this automatically but it doesn't do any harm to run it whenever you like.
npm start
http://localhost:8000/app/index.html
to see the app running in your browser.We recommend using Jasmine and Karma for your unit tests/specs, but you are free to use whatever works for you.
npm test
test/karma.conf.js
file.We recommend using Jasmine and Protractor for end-to-end testing.
Requires a webserver that serves the application. See Running the app during development, above.
npm start
.npm run protractor
. Protractor will execute the
end2end test scripts against the web application itself.
npm run update-webdriver
, and modify the
configuration at test/protractor-conf.js
.app/ --> all of the files to be used in production
css/ --> css files
app.css --> default stylesheet
img/ --> image files
index.html --> app layout file (the main html template file of the app)
js/ --> javascript files
app.js --> the main application module
controllers.js --> application controllers
controllers.js --> application directives
filters.js --> custom angular filters
services.js --> custom angular services
animations.js --> hooks for running JQuery animations with ngAnimate
partials/ --> angular view partials (partial html templates) used by ngRoute
partial1.html
partial2.html
bower_components --> 3rd party js libraries, including angular and jquery
scripts/ --> handy scripts
update-repo.sh --> pull down the latest version of this repos
(BE CAREFUL THIS DELETES ALL CHANGES YOU HAVE MADE)
private/ --> private scripts used by the Angular Team to maintain this repo
test/ --> test source files and libraries
karma.conf.js --> config file for running unit tests with Karma
protractor-conf.js --> config file for running e2e tests with Protractor
e2e/
scenarios.js --> end-to-end specs
unit/ --> unit level specs/tests
controllersSpec.js --> specs for controllers
directivesSpec.js --> specs for directives
filtersSpec.js --> specs for filters
servicesSpec.js --> specs for services
For more information on AngularJS please check out http://angularjs.org/