Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import { Component, OnInit } from '@angular/core';
- import {NavParams, AlertController} from "@ionic/angular";
- import { Person } from 'src/models/person.interface';
- import { Router } from '@angular/router';
- import { AngularFireAuth } from '@angular/fire/auth';
- import { AngularFirestore } from "@angular/fire/firestore";
- import 'firebase/firestore';
- @Component({
- selector: 'app-home',
- templateUrl: './home.page.html',
- styleUrls: ['./home.page.scss'],
- })
- export class HomePage implements OnInit {
- useremail: string = "";
- password: string = "";
- //hier wird das Objekt Person erstellt mit den Parametern Vorname und Nachname
- //person: Person = {}
- constructor(private alertCtrl: AlertController, private router: Router,public afAuth: AngularFireAuth, public afFirestore: AngularFirestore) {}
- async login() {
- const {useremail, password}=this
- try{
- const res = await this.afAuth.signInWithEmailAndPassword(useremail,password)
- console.log(res)
- }
- catch(err){
- console.dir(err)
- }
- }
- async write(){
- const {useremail, password}=this
- try{
- const res= await this.afFirestore.doc('shirt/ZbdOOOcwtJnoVOJlvYHs').set({
- bsrfb: "dv",
- imgurlfb: "fsv",
- namefb: "fvrrr"
- })
- console.log(res)
- }
- catch(err){
- console.dir(err)
- }
- }
- log(x){
- console.log(Object.values(x)[0])
- }
- async read(){
- const {useremail, password}=this
- try{
- const res= await this.afFirestore.doc('shirt/ZbdOOOcwtJnoVOJlvYHs').valueChanges().subscribe(action => { this.log(action)});
- //console.log(Object.values(res))
- // .set({
- // bsrfb: "dv",
- // imgurlfb: "fsv",
- // namefb: "fvrrr"
- // })
- console.log(res)
- }
- catch(err){
- console.dir(err)
- }
- }
- //Ist eine Funtion die ein Popup Alert erscheinen lässst
- hello(fn: string, ln: string ){
- //Hier wird das Popup beschrieben
- const alert = this.alertCtrl.create({
- header: fn,
- subHeader: ln,
- message: 'This is an alert message.',
- buttons: ['OK']
- })
- alert.then(alert=> alert.present());
- //gibt etwas in der Konsole aus
- //console.log(fn)
- }
- navto(wohin: string){
- this.router.navigate([wohin])
- }
- ngOnInit() {
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement