Skip to content
Go to file
Cannot retrieve contributors at this time
46 lines (42 sloc) 1.16 KB
The top-level component of the application.
Responsible for the login functionality, and showing the Battle component
when the user is logged in.
import { Component, NgZone } from '@angular/core';
import { AuthService } from '../services/authservice';
selector: 'app',
template: `
<h2>Github battle</h2>
<div *ngIf="!loginName">
You have to <button (click)="logIn()">log in</button>, otherwise Github's API limits won't let us have enough fun!
<div *ngIf="error">
Something went wrong :(
<div *ngIf="loginName">
Logged in as {{loginName}}.
export class AppComponent {
plrs = ["FOO",null,null]
error = null;
loginName: string
constructor(private authService: AuthService, private zone: NgZone){
authService.listenToAuthChanges((auth)=>{ => { // hack to fix Zones not registering Websocket stuff reliably
this.error = auth.error;
if (auth.token){
this.loginName = auth.user.displayName || auth.user.uid;
logIn() {
You can’t perform that action at this time.