This application takes the developer through the process of building a web-application using AngularJS. 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 the framework.
The full tutorial can be found at https://docs.angularjs.org/tutorial.
npm install
You can check out any point of the tutorial using:
git checkout step-?
To see the changes made between any two lessons use the git diff
command:
git diff step-?..step-?
ngApp
directive to bootstrap the application.PhoneListController
controller.ngRepeat
directive.PhoneListController
controller to show how to write tests and
run them using Karma.phoneList
component.phoneList
component..html
files (instead of inline HTML strings).filter
filter.ngRepeat
automatically shrinks and grows the number of phones in the view.age
property to the phone model.$http
service.services
and dependency injection
(DI):
$http
is injected into the controller through DI..$inject
and inline array$route
service, which allows binding URLs to views for routing and deep-linking:
ngRoute
module as a dependency.ngView
directive in 'index.html'./phones
):
/phones
to the existing phoneList
component./phones/:phoneId
):
/phones/:phoneId
to a new phoneDetail
component.phoneDetail
component, which displays the selected phone ID.phoneId
parameter to the component's controller via $routeParams
.$http
in PhoneDetailController
to fetch the phone details from a JSON file.checkmark
filter.phoneDetail
template to use the checkmark
filter.checkmark
filter.mainImageUrl
property on PhoneDetailController
.setImage()
method for changing the main image.ngClick
on the thumbnails to register a handler that changes the main image.$http
with $resource
.Phone
service that represents the RESTful client.ngRepeat
.ngView
.angular-phonecat
The following docs describe how you can test and develop this application further.
The application relies upon various JS libraries, such as AngularJS and jQuery, and Node.js tools, such as Karma and Protractor. You can install these by running:
npm install
This will also download the AngularJS files needed for the current step of the tutorial and copy
them to app/lib
.
Most of the scripts described below will run this automatically but it doesn't do any harm to run it whenever you like.
Note copying the AngularJS files from node_modules
to app/lib
makes it easier to serve the
files by a web server.
npm start
.We recommend using Jasmine and Karma for your unit tests/specs, but you are free to use whatever works for you.
npm test
.karma.conf.js
file.We recommend using Protractor for end-to-end (e2e) testing.
It requires a webserver that serves the application. See the Running the Application during Development section, above.
npm start
npm run protractor
.e2e-tests/protractor-conf.js
.Note:
Under the hood, Protractor uses the Selenium Standalone Server, which in turn requires
the Java Development Kit (JDK) to be installed on your local machine. Check this by running
java -version
from the command line.
If JDK is not already installed, you can download it here.
app/ --> all the source code of the app (along with unit tests)
lib/... --> 3rd party JS/CSS libraries, including AngularJS and jQuery (copied over from `node_modules/`)
core/ --> all the source code of the core module (stuff used throughout the app)
checkmark/... --> files for the `checkmark` filter, including JS source code, specs
phone/... --> files for the `core.phone` submodule, including JS source code, specs
core.module.js --> the core module
img/... --> image files
phone-detail/... --> files for the `phoneDetail` module, including JS source code, HTML templates, specs
phone-list/... --> files for the `phoneList` module, including JS source code, HTML templates, specs
phones/... --> static JSON files with phone data (used to fake a backend API)
app.animations.css --> hooks for running CSS animations with `ngAnimate`
app.animations.js --> hooks for running JS animations with `ngAnimate`
app.config.js --> app-wide configuration of AngularJS services
app.css --> default stylesheet
app.module.js --> the main app module
index.html --> app layout file (the main HTML template file of the app)
e2e-tests/ --> config and source files for e2e tests
protractor.conf.js --> config file for running e2e tests with Protractor
scenarios.js --> e2e specs
node_modules/... --> 3rd party libraries and development tools (fetched using `npm`)
scripts/ --> handy scripts
private/... --> private scripts used by the AngularJS Team to maintain this repo
update-repo.sh --> script for pulling down the latest version of this repo (!!! DELETES ALL CHANGES YOU HAVE MADE !!!)
karma.conf.js --> config file for running unit tests with Karma
package.json --> Node.js specific metadata, including development tools dependencies
package-lock.json --> Npm specific metadata, including versions of installed development tools dependencies
For more information on AngularJS, please check out https://angularjs.org/.