Skip to content

Instantly share code, notes, and snippets.

@JonForest
Created January 17, 2017 07:51
Show Gist options
  • Select an option

  • Save JonForest/d08b54bd7c0d70f34038e9efd3c84982 to your computer and use it in GitHub Desktop.

Select an option

Save JonForest/d08b54bd7c0d70f34038e9efd3c84982 to your computer and use it in GitHub Desktop.
import {Component, ChangeDetectorRef} from '@angular/core';
import {MdSnackBar} from '@angular/material';
declare const firebase: any; // declare the firebase global variable so Typescipt doesn't complain
@Component({
selector: 'app-root',
template: `
<button *ngIf="test" (click)="failedAttempt()">Click me</button>
`,
styleUrls: ['./app.component.css']
})
export class AppComponent {
test = false;
constructor(private ref: ChangeDetectorRef, private snackBar: MdSnackBar) {
firebase.auth().onAuthStateChanged((user) => {
this.test = true;
this.ref.detectChanges();
});
}
failedAttempt() {
this.snackBar.open('It didn\'t quite work!', 'Try Again', {duration: 2000});
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment