Skip to content
This repository was archived by the owner on Feb 26, 2024. It is now read-only.
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
3a03052
chore(lib): remove lib folder
Apr 23, 2014
856f32b
docs(README): add info about prerequisites
petebacondarwin May 3, 2014
caadfb8
fix(package.json): bind web server only to localhost
Mar 31, 2014
b76b5f5
feat(index): use html5-boilerplate HTML, modernizr and styles
petebacondarwin May 3, 2014
fbfde7c
feat(myApp.controllers): add $scope param to clarify annotation
petebacondarwin May 3, 2014
bdad3a4
chore(karma): add junit-reporter
michaelneale Apr 17, 2014
c42a34d
chore(bower): fix angular-mocks dependency
petebacondarwin May 3, 2014
d130400
test(controllers): provide $scope when instantiating controllers
petebacondarwin May 3, 2014
daf71f2
chore(bower): move bower_components under the app folder
petebacondarwin May 2, 2014
9cc6f6a
fix(index): remove invalid path references
May 4, 2014
05831d4
fix(index-async): correct the path to bower_components
petebacondarwin May 7, 2014
238b1a9
docs(README): fix typos
Khobalt May 13, 2014
0edde11
chore(travis): node js version should between quotes
saiqulhaq Jul 31, 2014
9d0b43b
refact(*): refactor app layout to conform to best practices
Mar 28, 2014
e5b915f
refact(*): update overall application architecture to match best prac…
addisonedwardlee Aug 20, 2014
0847b75
refact(*): further architectural improvements
petebacondarwin Aug 20, 2014
2dab434
chore(package.json): update to protractor 1.1.1
petebacondarwin Aug 31, 2014
1af9353
docs(README): fix link to Jasmine
ventuc Jul 21, 2014
ccb1d02
docs(README): fix grammar and ambiguous sentence
Aug 22, 2014
c85d961
docs(scenarios): fix link to protractor docs
alxfv Jul 10, 2014
20e8bb2
chore(package.json): remove local HTTP server's cache-control header
joewhite May 23, 2014
01191df
chore(package.json): fix path to angular-load.min.js.map in "update-i…
Jun 1, 2014
fd43437
docs(README): fix typo
mikaelharsjo Sep 23, 2014
6ca94d4
refact(index.html): remove self closing slash for link tag.
Oct 2, 2014
de30ee9
docs(README): add alternative git clone method
petebacondarwin Oct 29, 2014
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .bowerrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"directory": "app/bower_components"
}
9 changes: 8 additions & 1 deletion .jshintrc
Original file line number Diff line number Diff line change
@@ -1,6 +1,13 @@
{
"globalstrict": true,
"globals": {
"angular": false
"angular": false,
"describe": false,
"it": false,
"expect": false,
"beforeEach": false,
"afterEach": false,
"module": false,
"inject": false
}
}
6 changes: 3 additions & 3 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
language: node_js
node_js:
- 0.10
- "0.10"

before_script:
- export DISPLAY=:99.0
Expand All @@ -10,5 +10,5 @@ before_script:
- sleep 1 # give server time to start

script:
- node_modules/.bin/karma start test/karma.conf.js --no-auto-watch --single-run --reporters=dots --browsers=Firefox
- node_modules/.bin/protractor test/protractor-conf.js --browser=firefox
- node_modules/.bin/karma start karma.conf.js --no-auto-watch --single-run --reporters=dots --browsers=Firefox
- node_modules/.bin/protractor e2e-tests/protractor.conf.js --browser=firefox
98 changes: 59 additions & 39 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,14 @@ The seed app doesn't do much, just shows how to wire two controllers and views t

To get you started you can simply clone the angular-seed repository and install the dependencies:

### Prerequisites

You need git to clone the angular-seed repository. You can get git from
[http://git-scm.com/](http://git-scm.com/).

We also use a number of node.js tools to initialize and test angular-seed. You must have node.js and
its package manager (npm) installed. You can get them from [http://nodejs.org/](http://nodejs.org/).

### Clone angular-seed

Clone the angular-seed repository using [git][git]:
Expand All @@ -23,6 +31,14 @@ git clone https://github.com/angular/angular-seed.git
cd angular-seed
```

If you just want to start a new project without the angular-seed commit history then you can do:

```bash
git clone --depth=1 https://github.com/angular/angular-seed.git <your-project-name>
```

The `depth=1` tells git to only pull down one commit worth of historical data.

### Install Dependencies

We have two kinds of dependencies in this project: tools and angular framework code. The tools help
Expand All @@ -41,7 +57,11 @@ Behind the scenes this will also call `bower install`. You should find that you
folders in your project.

* `node_modules` - contains the npm packages for the tools we need
* `bower_components` - contains the angular framework files
* `app/bower_components` - contains the angular framework files

*Note that the `bower_components` folder would normally be installed in the root folder but
angular-seed changes this location through the `.bowerrc` file. Putting it in the app folder makes
it easier to serve the files by a webserver.*

### Run the Application

Expand All @@ -58,33 +78,33 @@ Now browse to the app at `http://localhost:8000/app/index.html`.

## Directory Layout

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)
index-async.html --> just like index.html, but loads js files asynchronously
js/ --> javascript files
app.js --> application
controllers.js --> application controllers
directives.js --> application directives
filters.js --> custom angular filters
services.js --> custom angular services
partials/ --> angular view partials (partial html templates)
partial1.html
partial2.html

test/ --> test config and source files
protractor-conf.js --> config file for running e2e tests with Protractor
e2e/ --> end-to-end specs
scenarios.js
karma.conf.js --> config file for running unit tests with Karma
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

```
app/ --> all of the source files for the application
app.css --> default stylesheet
components/ --> all app specific modules
version/ --> version related components
version.js --> version module declaration and basic "version" value service
version_test.js --> "version" value service tests
version-directive.js --> custom directive that returns the current app version
version-directive_test.js --> version directive tests
interpolate-filter.js --> custom interpolation filter
interpolate-filter_test.js --> interpolate filter tests
view1/ --> the view1 view template and logic
view1.html --> the partial template
view1.js --> the controller logic
view1_test.js --> tests of the controller
view2/ --> the view2 view template and logic
view2.html --> the partial template
view2.js --> the controller logic
view2_test.js --> tests of the controller
app.js --> main application module
index.html --> app layout file (the main html template file of the app)
index-async.html --> just like index.html, but loads js files asynchronously
karma.conf.js --> config file for running unit tests with Karma
e2e-tests/ --> end-to-end tests
protractor-conf.js --> Protractor config file
scenarios.js --> end-to-end scenarios to be run by Protractor
```

## Testing

Expand All @@ -96,8 +116,8 @@ The angular-seed app comes preconfigured with unit tests. These are written in
[Jasmine][jasmine], which we run with the [Karma Test Runner][karma]. We provide a Karma
configuration file to run them.

* the configuration is found at `test/karma.conf.js`
* the unit tests are found in `test/unit/`.
* the configuration is found at `karma.conf.js`
* the unit tests are found next to the code they are testing and are named as `..._test.js`.

The easiest way to run the unit tests is to use the supplied npm script:

Expand All @@ -107,7 +127,7 @@ npm test

This script will start the Karma test runner to execute the unit tests. Moreover, Karma will sit and
watch the source and test files for changes and then re-run the tests whenever any of them change.
This is the recommended strategy; if you unit tests are being run every time you save a file then
This is the recommended strategy; if your unit tests are being run every time you save a file then
you receive instant feedback on any changes that break the expected code functionality.

You can also ask Karma to do a single run of the tests and then exit. This is useful if you want to
Expand All @@ -125,8 +145,8 @@ The angular-seed app comes with end-to-end tests, again written in [Jasmine][jas
are run with the [Protractor][protractor] End-to-End test runner. It uses native events and has
special features for Angular applications.

* the configuration is found at `test/protractor-conf.js`
* the end-to-end tests are found in `test/e2e/`
* the configuration is found at `e2e-tests/protractor-conf.js`
* the end-to-end tests are found in `e2e-tests/scenarios.js`

Protractor simulates interaction with our web app and verifies that the application responds
correctly. Therefore, our web server needs to be serving up the application, so that Protractor
Expand Down Expand Up @@ -213,11 +233,11 @@ install the tool globally:
sudo npm install -g http-server
```

Then you can start your own development web server to server static files, from a folder, by
Then you can start your own development web server to serve static files from a folder by
running:

```
http-server
http-server -a localhost -p 8000
```

Alternatively, you can choose to configure your own webserver, such as apache or nginx. Just
Expand All @@ -226,12 +246,12 @@ configure your server to serve the files under the `app/` directory.

### Running the App in Production

This really depends on how complex is your app and the overall infrastructure of your system, but
This really depends on how complex your app is 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.
somewhere 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
Expand Down Expand Up @@ -271,7 +291,7 @@ For more information on AngularJS please check out http://angularjs.org/
[npm]: https://www.npmjs.org/
[node]: http://nodejs.org
[protractor]: https://github.com/angular/protractor
[jasmine]: http://pivotal.github.com/jasmine/
[jasmine]: http://jasmine.github.io
[karma]: http://karma-runner.github.io
[travis]: https://travis-ci.org/
[http-server]: https://github.com/nodeapps/http-server
[http-server]: https://github.com/nodeapps/http-server
File renamed without changes.
12 changes: 12 additions & 0 deletions app/app.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
'use strict';

// Declare app level module which depends on views, and components
angular.module('myApp', [
'ngRoute',
'myApp.view1',
'myApp.view2',
'myApp.version'
]).
config(['$routeProvider', function($routeProvider) {
$routeProvider.otherwise({redirectTo: '/view1'});
}]);
9 changes: 9 additions & 0 deletions app/components/version/interpolate-filter.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
'use strict';

angular.module('myApp.version.interpolate-filter', [])

.filter('interpolate', ['version', function(version) {
return function(text) {
return String(text).replace(/\%VERSION\%/mg, version);
};
}]);
Original file line number Diff line number Diff line change
@@ -1,17 +1,13 @@
'use strict';

/* jasmine specs for filters go here */
describe('myApp.version module', function() {
beforeEach(module('myApp.version'));

describe('filter', function() {
beforeEach(module('myApp.filters'));


describe('interpolate', function() {
describe('interpolate filter', function() {
beforeEach(module(function($provide) {
$provide.value('version', 'TEST_VER');
}));


it('should replace VERSION', inject(function(interpolateFilter) {
expect(interpolateFilter('before %VERSION% after')).toEqual('before TEST_VER after');
}));
Expand Down
9 changes: 9 additions & 0 deletions app/components/version/version-directive.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
'use strict';

angular.module('myApp.version.version-directive', [])

.directive('appVersion', ['version', function(version) {
return function(scope, elm, attrs) {
elm.text(version);
};
}]);
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
'use strict';

/* jasmine specs for directives go here */
describe('myApp.version module', function() {
beforeEach(module('myApp.version'));

describe('directives', function() {
beforeEach(module('myApp.directives'));

describe('app-version', function() {
describe('app-version directive', function() {
it('should print current version', function() {
module(function($provide) {
$provide.value('version', 'TEST_VER');
Expand Down
8 changes: 8 additions & 0 deletions app/components/version/version.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
'use strict';

angular.module('myApp.version', [
'myApp.version.interpolate-filter',
'myApp.version.version-directive'
])

.value('version', '0.1');
11 changes: 11 additions & 0 deletions app/components/version/version_test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
'use strict';

describe('myApp.version module', function() {
beforeEach(module('myApp.version'));

describe('version service', function() {
it('should return current version', inject(function(version) {
expect(version).toEqual('0.1');
}));
});
});
Empty file removed app/css/.gitkeep
Empty file.
Empty file removed app/img/.gitkeep
Empty file.
20 changes: 12 additions & 8 deletions app/index-async.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,14 @@
<html lang="en">
<head>
<meta charset="utf-8">
<link rel="stylesheet" href="bower_components/html5-boilerplate/css/normalize.css">
<link rel="stylesheet" href="bower_components/html5-boilerplate/css/main.css">
<style>
[ng-cloak] {
display: none;
}
</style>
<script src="bower_components/html5-boilerplate/js/vendor/modernizr-2.6.2.min.js"></script>
<script>
// include angular loader, which allows the files to load in any order
//@@NG_LOADER_START@@
Expand All @@ -25,20 +28,21 @@

// load all of the dependencies asynchronously.
$script([
'../bower_components/angular/angular.js',
'../bower_components/angular-route/angular-route.js',
'js/app.js',
'js/services.js',
'js/controllers.js',
'js/filters.js',
'js/directives.js'
'bower_components/angular/angular.js',
'bower_components/angular-route/angular-route.js',
'app.js',
'view1/view1.js',
'view2/view2.js',
'components/version/version.js',
'components/version/version-directive.js',
'components/version/interpolate-filter.js'
], function() {
// when all is done, execute bootstrap angular application
angular.bootstrap(document, ['myApp']);
});
</script>
<title>My AngularJS App</title>
<link rel="stylesheet" href="css/app.css">
<link rel="stylesheet" href="app.css">
</head>
<body ng-cloak>
<ul class="menu">
Expand Down
Loading