Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import { Component } from '@angular/core';
- import { OnInit } from '@angular/core/src/metadata/lifecycle_hooks';
- import { AngularFirestore, AngularFirestoreCollection, AngularFirestoreDocument } from 'angularfire2/firestore';
- import { Observable } from 'rxjs/Observable';
- import { map } from 'rxjs/operator/map';
- import { TaskService } from './task.service';
- import { AuthService } from './auth.service';
- @Component({
- selector: 'app-root',
- templateUrl: './app.component.html',
- styleUrls: ['./app.component.scss']
- })
- export class AppComponent implements OnInit {
- text: string;
- priority: string;
- tasks: any;
- currentUser: any;
- constructor(private taskService: TaskService, private authService: AuthService) {}
- ngOnInit() {
- this.tasks = this.taskService.tasksCollection.valueChanges();
- this.authService.currentUser.subscribe(user => {
- this.currentUser = user;
- });
- }
- addTask() {
- this.taskService.addTask({'text': this.text, 'priority': this.priority, 'isDone': false});
- console.log(this.currentUser.uid);
- }
- archiveTask(taskID: string) {
- this.taskService.updateTask(taskID, { 'isDone': true });
- }
- loginGoogle() {
- this.authService.loginGoogle();
- }
- logout() {
- this.authService.logout();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement