Advertisement
Guest User

Untitled

a guest
Mar 30th, 2020
93
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.31 KB | None | 0 0
  1. import { Component, OnInit } from '@angular/core';
  2. import {NavParams, AlertController} from "@ionic/angular";
  3. import { Person } from 'src/models/person.interface';
  4. import { Router } from '@angular/router';
  5. import { AngularFireAuth } from '@angular/fire/auth';
  6. import { AngularFirestore } from "@angular/fire/firestore";
  7. import 'firebase/firestore';
  8.  
  9. @Component({
  10. selector: 'app-home',
  11. templateUrl: './home.page.html',
  12. styleUrls: ['./home.page.scss'],
  13. })
  14. export class HomePage implements OnInit {
  15.  
  16.  
  17. useremail: string = "";
  18. password: string = "";
  19.  
  20. //hier wird das Objekt Person erstellt mit den Parametern Vorname und Nachname
  21. //person: Person = {}
  22.  
  23.  
  24.  
  25.  
  26. constructor(private alertCtrl: AlertController, private router: Router,public afAuth: AngularFireAuth, public afFirestore: AngularFirestore) {}
  27.  
  28.  
  29. async login() {
  30. const {useremail, password}=this
  31.  
  32.  
  33. try{
  34.  
  35. const res = await this.afAuth.signInWithEmailAndPassword(useremail,password)
  36. console.log(res)
  37. }
  38.  
  39.  
  40. catch(err){
  41. console.dir(err)
  42. }
  43.  
  44. }
  45.  
  46.  
  47. async write(){
  48.  
  49. const {useremail, password}=this
  50.  
  51.  
  52.  
  53. try{
  54.  
  55. const res= await this.afFirestore.doc('shirt/ZbdOOOcwtJnoVOJlvYHs').set({
  56.  
  57. bsrfb: "dv",
  58. imgurlfb: "fsv",
  59. namefb: "fvrrr"
  60. })
  61.  
  62.  
  63.  
  64. console.log(res)
  65. }
  66.  
  67.  
  68. catch(err){
  69. console.dir(err)
  70. }
  71.  
  72.  
  73.  
  74.  
  75.  
  76. }
  77.  
  78. log(x){
  79. console.log(Object.values(x)[0])
  80.  
  81. }
  82.  
  83. async read(){
  84.  
  85. const {useremail, password}=this
  86.  
  87.  
  88.  
  89. try{
  90.  
  91. const res= await this.afFirestore.doc('shirt/ZbdOOOcwtJnoVOJlvYHs').valueChanges().subscribe(action => { this.log(action)});
  92. //console.log(Object.values(res))
  93. // .set({
  94.  
  95. // bsrfb: "dv",
  96. // imgurlfb: "fsv",
  97. // namefb: "fvrrr"
  98. // })
  99.  
  100.  
  101.  
  102. console.log(res)
  103. }
  104.  
  105.  
  106. catch(err){
  107. console.dir(err)
  108. }
  109. }
  110.  
  111. //Ist eine Funtion die ein Popup Alert erscheinen lässst
  112. hello(fn: string, ln: string ){
  113.  
  114.  
  115. //Hier wird das Popup beschrieben
  116. const alert = this.alertCtrl.create({
  117. header: fn,
  118. subHeader: ln,
  119. message: 'This is an alert message.',
  120. buttons: ['OK']
  121. })
  122.  
  123. alert.then(alert=> alert.present());
  124.  
  125.  
  126. //gibt etwas in der Konsole aus
  127. //console.log(fn)
  128.  
  129. }
  130.  
  131. navto(wohin: string){
  132.  
  133. this.router.navigate([wohin])
  134.  
  135. }
  136.  
  137. ngOnInit() {
  138. }
  139.  
  140. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement