Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import {Component} from '@angular/core';
- import { Response } from '@angular/http';
- import {RecipeDataService} from '../shared/RecipeData.service';
- import {SignupUserService} from '../auth/signupUser.service';
- @Component({
- selector: 'app-header',
- templateUrl: './header.component.html',
- styleUrls: ['./header.component.css']
- })
- export class HeaderComponent {
- constructor(private RecipeDataService: RecipeDataService,
- private authService: SignupUserService) { }
- OnSave()
- {
- this.RecipeDataService.OnSaveRecipe()
- .subscribe(
- (response: Response) =>
- {
- console.log(response);
- }
- );
- }
- OnGet()
- {
- this.RecipeDataService.OnGettingRecipe();
- }
- }
- И содержимое сервиса, на который ссылаюсь:
- import {Injectable} from '@angular/core';
- import * as firebase from 'firebase';
- @Injectable()
- export class SignupUserService {
- token = '';
- signUpUser(email: string, password: string) {
- firebase.auth().createUserWithEmailAndPassword(email, password)
- .catch(
- error => console.log(error)
- );
- }
- signInUser(email: string, password: string)
- {
- firebase.auth().signInWithEmailAndPassword(email, password)
- .then(
- response => {
- firebase.auth().currentUser.getIdToken()
- .then(
- (token: string) => this.token = token
- );
- }
- )
- .catch (
- error => {console.log(error); }
- );
- }
- getToken() {
- firebase.auth().currentUser.getIdToken()
- .then(
- (token: string) => this.token = token
- );
- return this.token;
- }
- isAuthenticated(): boolean
- {
- return this.token != null;
- }
- }
- constructor(private RecipeDataService: RecipeDataService,
- public authService: SignupUserService) { }
Add Comment
Please, Sign In to add comment