This project is an application skeleton for a typical AngularJS web app. You can use it to quickly bootstrap your angular webapp projects and dev environment for these projects.
This is for those who need the implementation of a light-weight sign-in functionality. Thus a social provider, such as Google or Facebook, can help you to provide this requirement with no major effort by letting you to put focus in the core of your business. Here you'll working some concepts of the OAuth2.0 RFC, thus this app follows the implicit grant flow as being a client-side only app. At the moment of writing, this app support sign-in user with Google, for more information about how this Identity provider, IDP support this functionality can be find here.
The seed contains AngularJS libraries, test libraries and a bunch of scripts all preconfigured for instant web development gratification. Just clone the repo (or download the zip/tarball), start up our (or yours) webserver and you are ready to develop and test your application.
The seed app doesn't do much, just shows how to wire two controllers and views together. You can
check it out by opening app/index.html in your browser (might not work file file://
scheme in
certain browsers, see note below).
Note: While angular is client-side-only technology and it's possible to create angular webapps that
don't require a backend server at all, we recommend hosting the project files using a local
webserver during development to avoid issues with security restrictions (sandbox) in browsers. The
sandbox implementation varies between browsers, but quite often prevents things like cookies, xhr,
etc to function properly when an html page is opened via file://
scheme instead of http://
.
Clone the angular-oauth20-seed repository and start hacking...
You can pick one of these options:
- serve this repository with your webserver
- install node.js and run
scripts/web-server.js
Then navigate your browser to http://localhost:<port>/app/index.html
to see the app running in
your browser.
For running this app and interacting with Google, you'll need to go to the Google Cloud Console and registering there a new application. There are two required steps you need to perform here:
- register a redirect URI, in this case:
http://localhost:<port>/app/dashboard.html
- grab the google client id assigned to your app and replace the string
YOUR_GOOGLE_OAUTH20_CLIENT_ID
locatedapp/configurations.js
with this
This really depends on how complex is your app and the overall infrastructure of your system, but
the general rule is that all you need in production are all the files under the app/
directory.
Everything else should be omitted.
Angular apps are really just a bunch of static html, css and js files that just need to be hosted somewhere, where they can be accessed by browsers.
If your Angular app is talking to the backend server via xhr or other means, you need to figure out what is the best way to host the static files to comply with the same origin policy if applicable. Usually this is done by hosting the files by the backend server or through reverse-proxying the backend server(s) and a webserver(s).
We recommend using jasmine and Karma for your unit tests/specs, but you are free to use whatever works for you.
Requires node.js, Karma (sudo npm install -g karma
) and a local
or remote browser.
- start
scripts/test.sh
(on windows:scripts\test.bat
)- a browser will start and connect to the Karma server (Chrome is default browser, others can be captured by loading the same url as the one in Chrome or by changing the
config/karma.conf.js
file)
- a browser will start and connect to the Karma server (Chrome is default browser, others can be captured by loading the same url as the one in Chrome or by changing the
- to run or re-run tests just change any of your source or test javascript files
We recommend using protractor for end-to-end tests. It uses native events and has special features for Angular applications.
Requires a webserver, node.js + ./scripts/web-server.js
or your backend server that hosts the angular static files.
- create your end-to-end tests in
test/e2e/scenarios.js
- serve your project directory with your http/backend server or node.js +
scripts/web-server.js
- to run:
- run the tests from console with Protractor via
scripts/e2e-test.sh
(on windows:scripts\e2e-test.bat
)
- run the tests from console with Protractor via
app/ --> all of the files to be used in production
css/ --> css files
app.css --> default stylesheet
img/ --> image files
dashboard.html --> app layout file (the main html template file of the app)
index.html --> html file
js/ --> javascript files
app.js --> application
configurations.js --> application configurations
controllers.js --> application controllers
directives.js --> application directives
filters.js --> custom angular filters
services.js --> custom angular services
lib/ --> angular and 3rd party javascript libraries
angular/
angular.js --> the latest angular js
angular.min.js --> the latest minified angular js
angular-*.js --> angular add-on modules
version.txt --> version number
partials/ --> angular view partials (partial html templates)
partial1.html
partial2.html
config/karma.conf.js --> config file for running unit tests with Karma
config/protractor-conf.js --> config file for running e2e tests with Protractor
scripts/ --> handy shell/js/ruby scripts
e2e-test.sh --> runs end-to-end tests with Karma (*nix)
e2e-test.bat --> runs end-to-end tests with Karma (windows)
test.bat --> autotests unit tests with Karma (windows)
test.sh --> autotests unit tests with Karma (*nix)
web-server.js --> simple development webserver based on node.js
test/ --> test source files and libraries
e2e/ -->
scenarios.js --> end-to-end specs
lib/
angular/ --> angular testing libraries
angular-mocks.js --> mocks that replace certain angular services in tests
angular-scenario.js --> angular's scenario (end-to-end) test runner library
version.txt --> version file
unit/ --> unit level specs/tests
controllersSpec.js --> specs for controllers
directivessSpec.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/