This seed repo serves as an Angular 2 starter for anyone looking to get up and running with Angular 2 and TypeScript fast. Using a Webpack for building our files and assisting with boilerplate. We're also using Protractor for our end-to-end story and Karma for our unit tests.
- Best practices in file and application organization for Angular 2.
- Ready to go build system using Webpack for working with TypeScript.
- Angular 2 examples that are ready to go when experimenting with Angular 2.
- A great Angular 2 seed repo for anyone who wants to start their project.
- Testing Angular 2 code with Jasmine and Karma.
- Coverage with Istanbul and Karma
- End-to-end Angular 2 code using Protractor.
- Type manager with tsd
You will need the following things properly installed on your computer.
- Git
- Node.js (with NPM)
Ensure you're running the latest versions Node
v4.1.x
+ and NPM2.14.x
+ - PhantomJS
typescript
(npm install --global typescript
)
Clone/Download the repo then edit
app.ts
inside/src/app/app.ts
# clone our repo
git clone https://github.com/mattma/angular2-rocks
# change directory to our repo
cd angular2-rocks
# install the repo with npm
npm install
# start the server
npm start
# go to `http://localhost:4200` in your browser
open http://localhost:4200
We use the component approach in our starter. This is the new standard for developing Angular apps and a great way to ensure maintainable code by encapsulation of our behavior logic. A component is basically a self contained app usually in a single file or a folder with each concern as a file: style, template, specs, e2e, and component class. Here's how it looks:
angular2-webpack-starter/
├──src/ * source files that will be compiled to javascript
| ├──main.ts * entry file for our browser environment
│ │
| ├──index.html * Index.html: where we generate our index page
│ │
| ├──vendor.ts * vendor file
│ │
│ ├──app/ * WebApp: folder
│ │ ├──app.spec.ts * a simple test of components in app.ts
│ │ └──app.ts * a simple version of our App component
│ │
│ └──assets/ * static assets are served here
│ ├──service-worker.js * ignore this. Web App service worker that's not complete yet
│ ├──robots.txt * for search engines to crawl your website
│ └──human.txt * for humans to know who the developers are
│
├──test/ * global unit tests and end-to-end tests
│
├──spec-bundle.js * ignore this magic that sets up our angular 2 testing environment
├──karma.config.js * karma config for our unit tests
├──protractor.config.js * protractor config for our end-to-end tests
│
├──tsconfig.json * config that webpack uses for typescript
├──tsd.json * typings manager
├──package.json * what npm uses to manage it's dependencies
│
├──webpack.config.js * development webpack config
├──webpack.test.config.js * testing webpack config
└──webpack.prod.config.js * production webpack config
The benefit of using immutable data is that dirty checking does not need to perform a deep equality check. If every mutation returns a new object, dirty checking can use a blazingly fast strict equality check
npm start # alias: npm run server:dev
npm run server # (default: dev)
npm run server:dev
npm run server:prod
It starts a local server using webpack-dev-server
which will watch, build (in-memory), and reload for you. The port will be displayed to you as http://0.0.0.0:4200
(or if you prefer IPv6, if you're using express
server, then it's http://[::1]:4200/
).
npm run build # (default: prod)
npm run build:dev
npm run build:prod
When build
command is run, it will auto trigger an clean method to remove existing dist
folder, so it will make sure that it always have up-to-date build files.
npm run watch # (default: dev)
npm run watch:dev
npm run watch:prod
npm run test
npm run e2e
npm run ci # run both e2e and test
make sure you have webdriver running and a sever for the client app before you run e2e
tests.
webdriver scripts can be used for end-to-end.
npm run webdriver:update
npm run webdriver:start
npm run clean
npm run clean:dist
npm run lint
npm run tsd
npm run tsd:clean
npm run doc
It will generate the documenation of the current application via typedoc.
To take full advantage of TypeScript with autocomplete you would have to install it globally and use an editor with the correct TypeScript plugins.
TypeScript 1.7.x includes everything you need. Make sure to upgrade, even if you installed TypeScript previously. Do now npm install --global typescript
.
-
What's the current browser support for Angular 2 Beta?
- Please view the updated list of browser support for Angular 2
-
Why is my service, aka provider, is not injecting parameter correctly?
- Please use
@Injectable()
for your service for typescript to correctly attach the metadata (this is a TypeScript problem)
- Please use
-
How do I start the app when I get
EACCES
andEADDRINUSE
errors?- The
EADDRINUSE
error means the port3000
is currently being used andEACCES
is lack of permission for webpack to build files to./dist/
- The
-
How to use
sass
for css? -
loaders: ['raw-loader','sass-loader']
and@Component({ styles: [ require('./filename.scss') ] })
see issue #136 -
How do I test a Service?
-
See issue #130
-
How do I make the repo work in a virtual machine?
- You need to use
0.0.0.0
so revert these changes #205
- You need to use
-
What are the naming conventions for Angular 2?
- ng2-play (Pawel Kozlowski)
- Client only, Minimalist, SystemJS, Gulp, TypeScript
- angular2-seed (Minko Gechev)
- Client only, SystemJS, Gulp, TypeScript, TSD, Versioned, Env Dev/Prod
- ng2-lab (Roland Groza)
- Client only, ES6, TypeScript, Firebase, Gulp, Ci, TSD, TSLint
- ng2-jspm-seed (Rob Wormald)
- Client only, TypeScript, TSD, Gulp, JSPM, Minimalist
- babel-angular2-app (Shuhei Kagawa)
- Client only, Minimalist, Babel, ES6+, browserify
- Sites built with Angular2
- Angular official site
- Awesome angular2 and its web view
- Curated list of resources for learning how to Angular2
- angular2-tutorials
- Learn angular2
- Angular2 Education
- Angular2 Education
- Angular2 Learning
- Reddit Angular2 made for solving problems and asking questions about this new version of AngularJS.
- stackoverflow angular2
- thoughtram
- syntaxsuccess
- onehungrymind
- Angular2 Quickly
- Victor Savkin
- Jvan Demo
- Ionic Angular2 Series
- Angular2 on Flipboard
- bennadel
- try angular2 today
- The Beginner’s Preemptive Guide To AngularJS 2 Beta
- Angular 2 for AngularJS developers
- Angular VS React comparison
- Angular2 with redux
- projects to checkout
- [angular-cli]
npm install -g angular-cli@latest
to install - ng2Boilerplate
- projects with code samples
- angular2 universal starter server rendering
- Angular2 JumpStart
- angular2 seed
- angular2 samples
- ng2-webpack
- ng2-charts and Demo site
Special thanks to those projects to inspire angular2-rocks.
- Add
tsconfig
{
"compilerOptions": {
"noImplicitAny": true,
"suppressImplicitAnyIndexErrors": true
}
}
Copyright (c) 2016 Matt Ma
Angular2 Rocks is MIT Licensed.