Skip to content

Commit

Permalink
setup firebase
Browse files Browse the repository at this point in the history
  • Loading branch information
Branislav Remen committed Feb 13, 2017
1 parent 32834d9 commit 3ee89d8
Show file tree
Hide file tree
Showing 6 changed files with 77 additions and 1 deletion.
32 changes: 32 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,35 @@ Sample Angular 2 project created with angular CLI with firebase integrated using
Project generated with [angular-cli](https://github.com/angular/angular-cli)
* run `npm install`
* start local server with `npm start`

Sample db imports in folder `_resources`

**Don't forget to change db rules**
```
{
"rules": {
".read": "auth != null",
".write": "auth != null"
}
}
```
into
```
{
"rules": {
".read": "true",
".write": "true"
}
}
```

**Add your firebase keys into `./src/app/app.module.ts`**
```
// Must export the config
export const firebaseConfig = {
apiKey: '<your-key>',
authDomain: '<your-project-authdomain>',
databaseURL: '<your-database-URL>',
storageBucket: '<your-storage-bucket>'
};
```
18 changes: 18 additions & 0 deletions _resources/items.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
[
{
"body": "body one",
"name": "name 1"
},
{
"body": "body two",
"name": "name 2"
},
{
"body": "body three",
"name": "name 3"
},
{
"body": "body four",
"name": "name 4"
}
]
2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,9 @@
"@angular/platform-browser": "^2.3.1",
"@angular/platform-browser-dynamic": "^2.3.1",
"@angular/router": "^3.3.1",
"angularfire2": "^2.0.0-beta.7",
"core-js": "^2.4.1",
"firebase": "^3.6.9",
"rxjs": "^5.0.1",
"ts-helpers": "^1.1.1",
"zone.js": "^0.7.2"
Expand Down
6 changes: 6 additions & 0 deletions src/app/app.component.html
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
<h1>
{{title}}
</h1>

<ul>
<li class="text" *ngFor="let item of items | async">
{{item.name}}
</li>
</ul>
7 changes: 7 additions & 0 deletions src/app/app.component.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,17 @@
import { Component } from '@angular/core';

import { AngularFire, FirebaseListObservable } from 'angularfire2';

@Component({
selector: 'app-root',
templateUrl: './app.component.html',
styleUrls: ['./app.component.css']
})
export class AppComponent {
title = 'app works!';
items: FirebaseListObservable<any[]>;

constructor(private af: AngularFire) {
this.items = af.database.list('/items');
}
}
13 changes: 12 additions & 1 deletion src/app/app.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,25 @@ import { HttpModule } from '@angular/http';

import { AppComponent } from './app.component';

import {AngularFireModule} from 'angularfire2';

// Must export the config
export const firebaseConfig = {
apiKey: '<your-key>',
authDomain: '<your-project-authdomain>',
databaseURL: '<your-database-URL>',
storageBucket: '<your-storage-bucket>'
};

@NgModule({
declarations: [
AppComponent
],
imports: [
BrowserModule,
FormsModule,
HttpModule
HttpModule,
AngularFireModule.initializeApp(firebaseConfig)
],
providers: [],
bootstrap: [AppComponent]
Expand Down

0 comments on commit 3ee89d8

Please sign in to comment.