無需快遞
npm install angularfire2 firebase --save
這裏是一個例子,如何用火力地堡
import {Component} from '@angular/core';
import {AngularFire, FirebaseListObservable} from 'angularfire2';
@Component({
selector: 'project-name-app',
template: `
<ul>
<li *ngFor="let item of items | async">
{{ item.name }}
</li>
</ul>
`
})
export class MyApp {
items: FirebaseListObservable<any[]>;
constructor(af: AngularFire) {
this.items = af.database.list('/items');
}
}
使用它,但你可能需要使用快遞,從SEO的角度來看,這是使應用程序在服務器端
import * as express from 'express';
import {ng2engine} from 'angular2-universal-preview';
// Angular 2
import {App} from './src/app';
let app = express();
// Express View
app.engine('.ng2.html', ng2engine);
app.set('views', __dirname);
app.set('view engine', 'ng2.html');
// static files
app.use(express.static(__dirname));
app.use('/', (req, res) => {
res.render('index', { App });
});
app.listen(3000,() => {
console.log('Listen on http://localhost:3000');
});
您鏈接的答案似乎仍然準確。推薦其中一個是堆棧溢出的主題。 –