Skip to content

Commit e7a9c86

Browse files
committed
added step 57
1 parent 21b111d commit e7a9c86

25 files changed

+6846
-1
lines changed

step56_firebase/app/app.component.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

step56_firebase/app/app.component.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ export class AppComponent {
1717
constructor(af: AngularFire) {
1818
this.af = af;
1919
this.items = af.database.list('items');
20+
2021
}
2122

2223
}

step57_firebase_list/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
node_modules

step57_firebase_list/app/app.component.js

Lines changed: 39 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

step57_firebase_list/app/app.component.js.map

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
import { Component } from '@angular/core';
2+
import { AngularFire, FirebaseListObservable } from 'angularfire2';
3+
4+
@Component({
5+
selector: 'my-app',
6+
template: `
7+
<ul>
8+
<li *ngFor="let item of items | async">
9+
<input type="text" #update [value]="item.text" />
10+
<button (click)="update(item.$key, update.value)">Update</button>
11+
<button (click)="deleteItem(item.$key)">Delete</button>
12+
</li>
13+
</ul>
14+
<input type="text" #newitem />
15+
<button (click)="add(newitem.value)">Add</button>
16+
<button (click)="deleteEverything()">Delete All</button>
17+
`,
18+
})
19+
export class AppComponent {
20+
items: FirebaseListObservable<any>;
21+
constructor(af: AngularFire) {
22+
this.items = af.database.list('/messages');
23+
}
24+
add(newName: string) {
25+
this.items.push({ text: newName });
26+
}
27+
update(key: string, name: string) {
28+
this.items.update(key, { name: name });
29+
}
30+
deleteItem(key: string) {
31+
this.items.remove(key);
32+
}
33+
deleteEverything() {
34+
this.items.remove();
35+
}
36+
}

step57_firebase_list/app/main.js

Lines changed: 15 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

step57_firebase_list/app/main.js.map

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

step57_firebase_list/app/main.ts

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
import { bootstrap } from '@angular/platform-browser-dynamic';
2+
import { AppComponent } from './app.component';
3+
import { FIREBASE_PROVIDERS, defaultFirebase } from 'angularfire2';
4+
5+
6+
bootstrap(AppComponent, [
7+
FIREBASE_PROVIDERS,
8+
// Initialize Firebase app
9+
defaultFirebase({
10+
apiKey: "",
11+
authDomain: "",
12+
databaseURL: "",
13+
storageBucket: "",
14+
})
15+
]);
16+
17+
18+
19+
20+
21+
22+

step57_firebase_list/index.html

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
<html>
2+
<head>
3+
<title>Angular 2 QuickStart</title>
4+
<meta charset="UTF-8">
5+
<meta name="viewport" content="width=device-width, initial-scale=1">
6+
<link rel="stylesheet" href="styles.css">
7+
<!-- 1. Load libraries -->
8+
<!-- Polyfill(s) for older browsers -->
9+
<script src="node_modules/core-js/client/shim.min.js"></script>
10+
<script src="node_modules/zone.js/dist/zone.js"></script>
11+
<script src="node_modules/reflect-metadata/Reflect.js"></script>
12+
<script src="node_modules/systemjs/dist/system.src.js"></script>
13+
<!-- 2. Configure SystemJS -->
14+
<script src="systemjs.config.js"></script>
15+
<script>
16+
System.import('app').catch(function(err){ console.error(err); });
17+
</script>
18+
</head>
19+
<!-- 3. Display the application -->
20+
<body>
21+
<my-app>Loading...</my-app>
22+
</body>
23+
</html>
24+

0 commit comments

Comments
 (0)