npm install -g angular-cli
ng new PROJECT_NAME
cd PROJECT_NAME
ng serve
http://localhost:4200/ng generate component my-new-component
ng g component my-new-component //using the alias
//components support relative path generation
//if in the directory src/app/feature/ and you run
ng g component new-cmp
//your component will be generated in src/app/feature/new-cmp
//but if you were to run
ng g component ../newer-cmp
//your component will be generated in src/app/newer-cmpng generate route heroThis will create a folder which will contain the hero component and related test and style files.
The generated route will also be registered with the parent component's @RouteConfig decorator.
By default the route will be designated as a lazy route which means that it will be loaded into the browser when needed, not upfront as part of a bundle.
In order to visually distinguish lazy routes from other routes the folder for the route will be prefixed with a + per the above example the folder will be named +hero.
ng buildThe build artifacts will be stored in the dist/ directory.
ng testests will execute after a build is executed via Karma, and it will automatically watch your files for changes.
You can run tests a single time via --watch=false, and turn off building of the app via --build=false (useful for running it at the same time as ng serve).
ng e2eBefore running the tests make sure you are serving the app via ng serve.
ng github-pages:deploy --message "Optional commit message"This will do the following:
ng github-pages:deploy --message "Optional commit message"This will do the following:
AngularFire2 integrates Firebase's realtime observers and authentication with Angular2.
import {Component} from 'angular2/core';
import {AngularFire} from 'angularfire2';
import {Observable} from 'rxjs/Observable';
@Component({
selector: 'project-name-app',
providers: [],
templateUrl: 'app/project-name-app.html',
directives: [],
pipes: []
})
export class MyApp {
items: Observable<any[]>;
constructor(af: AngularFire) {
this.items = af.list('/items');
}
}ng new <project-name>
cd <project-name>npm install angularfire2 firebase --savenpm install typings -g
typings install --save --global firebaseOpen typings.
{
"globalDevDependencies": {
"angular-protractor": "registry:dt/angular-protractor#1.5.0+20160425143459",
"jasmine": "registry:dt/jasmine#2.2.0+20160412134438",
"selenium-webdriver": "registry:dt/selenium-webdriver#2.44.0+20160317120654"
},
"globalDependencies": {
"es6-shim": "registry:dt/es6-shim#0.31.2+20160317120654"
}
}
typings install/* global require, module */
var Angular2App = require('angular-cli/lib/broccoli/angular2-app');
module.exports = function(defaults) {
var app = new Angular2App(defaults, {
vendorNpmFiles: [
'angularfire2/**/*.js',
'firebase/lib/*.js'
]
});
return app.toTree();
}ng buildSystem.config({
map: {
firebase: 'vendor/firebase/lib/firebase-web.js',
angularfire2: 'vendor/angularfire2'
},
packages: {
app: {
format: 'register',
defaultExtension: 'js'
},
angularfire2: {
defaultExtension: 'js',
main: 'angularfire2.js'
}
}
});import {bootstrap} from 'angular2/platform/browser';
import {MyAppClass} from './app/<my-app-class>';
import {ROUTER_PROVIDERS} from 'angular2/router';
import {FIREBASE_PROVIDERS, defaultFirebase, AngularFire} from 'angularfire2';
bootstrap(<MyAppClass>, [
FIREBASE_PROVIDERS,
defaultFirebase('https://<your-firebase>.firebaseio.com'),
ROUTER_PROVIDERS
]);import {Component} from 'angular2/core';
import {RouteConfig, ROUTER_DIRECTIVES} from 'angular2/router';
import {AngularFire} from 'angularfire2';
import {Observable} from 'rxjs/Observable';
@Component({
selector: 'project-name-app',
providers: [],
templateUrl: 'app/project-name-app.html',
directives: [ROUTER_DIRECTIVES],
pipes: []
})
@RouteConfig([
])
export class ProjectNameApp {
constructor(af: AngularFire) {
}
}import {Component} from 'angular2/core';
import {RouteConfig, ROUTER_DIRECTIVES} from 'angular2/router';
import {AngularFire} from 'angularfire2';
import {Observable} from 'rxjs/Observable';
@Component({
selector: 'project-name-app',
providers: [],
templateUrl: 'app/project-name-app.html',
directives: [ROUTER_DIRECTIVES],
pipes: []
})
@RouteConfig([
])
export class ProjectNameApp {
items: Observable<any[]>;
constructor(af: AngularFire) {
// create a list at /items
this.items = af.list('/items');
}
}<ul *ngFor="#item of items | async">
<li class="text">
{{item}}
</li>
</ul>ng serveRun the
import {Component} from 'angular2/core';
import {bootstrap} from 'angular2/platform/browser';
import {Observable} from 'rxjs/Observable';
import {FIREBASE_PROVIDERS, defaultFirebase, AngularFire} from 'angularfire2';
import {Question} from './services/question';
@Component({
template:`
<ul>
<li *ngFor="#question of questions | async">
{{question.text}}
</li>
</ul>
`
})
class App {
questions:Observable<Question[]>
constructor(af:AngularFire) {
// Get an observable of a synchronized array from <firebase-root>/questions
this.questions = af.list('/questions');
}
}
bootstrap(App, [
// Common injectable providers from the AngularFire lib
FIREBASE_PROVIDERS,
// Tell AngularFire the base URL for the Firebase used throughout
defaultFirebase('https://<some-firebase>.firebaseio.com')
]);