Advertisement
Guest User

Untitled

a guest
Nov 19th, 2017
65
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import { Component } from '@angular/core';
  2. import { OnInit } from '@angular/core/src/metadata/lifecycle_hooks';
  3.  
  4. import { AngularFirestore, AngularFirestoreCollection, AngularFirestoreDocument } from 'angularfire2/firestore';
  5.  
  6. import { Observable } from 'rxjs/Observable';
  7. import { map } from 'rxjs/operator/map';
  8.  
  9. import { TaskService } from './task.service';
  10. import { AuthService } from './auth.service';
  11.  
  12.  
  13. @Component({
  14.   selector: 'app-root',
  15.   templateUrl: './app.component.html',
  16.   styleUrls: ['./app.component.scss']
  17. })
  18. export class AppComponent implements OnInit {
  19.   text: string;
  20.   priority: string;
  21.  
  22.   tasks: any;
  23.  
  24.   currentUser: any;
  25.  
  26.   constructor(private taskService: TaskService, private authService: AuthService) {}
  27.  
  28.   ngOnInit() {
  29.     this.tasks = this.taskService.tasksCollection.valueChanges();
  30.     this.authService.currentUser.subscribe(user => {
  31.       this.currentUser = user;
  32.     });
  33.   }
  34.  
  35.   addTask() {
  36.     this.taskService.addTask({'text': this.text, 'priority': this.priority, 'isDone': false});
  37.     console.log(this.currentUser.uid);
  38.   }
  39.  
  40.   archiveTask(taskID: string) {
  41.     this.taskService.updateTask(taskID, { 'isDone': true });
  42.   }
  43.  
  44.   loginGoogle() {
  45.     this.authService.loginGoogle();
  46.   }
  47.  
  48.   logout() {
  49.     this.authService.logout();
  50.   }
  51. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement