Instantly share code, notes, and snippets.

View ng-providers.api-service-register2.ts
import { ApiService } from 'app/api.service';
@NgModule({
declarations: [AppComponent],
imports: [BrowserModule],
providers: [
{ provide: ApiService, useClass: ApiService }
],
bootstrap: [AppComponent]
})
View ng-providers.api-service-register.ts
import { ApiService } from './api.service';
@NgModule({
declarations: [AppComponent],
imports: [BrowserModule],
providers: [
ApiService
],
bootstrap: [AppComponent]
})
View profileDataError.resolver.ts
initProfileData(): void {
this.store.take(1).subscribe(store => {
if (!store.profile.profileData) {
this.apiService.getProfileData().toPromise()
.then(data => {
this.store.dispatch(new profileActions.UpdateAction(data));
})
.catch(err => {
this.router.navigate(['/404'])
});
View wc-index.html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Web components loader</title>
<link rel="import" href="./apps/angular-app.html">
<link rel="import" href="./apps/react-app.html">
</head>
<body>
<h1>Hello web-components</h1>
View .firebaserc
{
"projects": {
"default": "ng-firebase-dev",
"develop": "ng-firebase-dev",
"production": "ng-firebase-241bb"
}
}
View ng-firebase.gitlab-ci.yml
.node: &node
image: node:7
before_script:
- npm install
cache:
key: "$CI_COMMIT_REF_NAME"
paths:
- node_modules/
stages:
View ng-firebase.npm-scripts.json
"scripts": {
"ng": "ng",
"start": "ng serve",
"build": "ng build",
"test": "ng test",
"lint": "ng lint",
"e2e": "ng e2e",
"predeploy": "firebase use --token $FIREBASE_DEPLOY_KEY $CI_ENVIRONMENT_SLUG",
"deploy": "firebase deploy --non-interactive --token $FIREBASE_DEPLOY_KEY"
}
View firebase.json
{
"database": {
"rules": {
".read": "true",
".write": "true"
}
},
"hosting": {
"public": "dist",
"rewrites": [{
View ng-firebase.app.component.html
<ul>
<li *ngFor="let item of items | async">
<input type="text" #updatetext [value]="item.text" />
<button (click)="updateItem(item.key, updatetext.value)">Update</button>
<button (click)="deleteItem(item.key)">Delete</button>
</li>
</ul>
<input type="text" #newitem />
<button (click)="addItem(newitem.value)">Add</button>
<button (click)="deleteEverything()">Delete All</button>
View ng-firebase.app.component.ts
import { Component } from '@angular/core';
import { AngularFireDatabase, AngularFireList } from 'angularfire2/database';
import { Observable } from 'rxjs/Observable';
@Component({
selector: 'app-root',
templateUrl: './app.component.html',
styleUrls: ['./app.component.css']
})
export class AppComponent {