Readdy Write  
0,00 €
Your View Money
Views: Count
Self 20% 0
Your Content 60% 0

Users by Links 0
u1*(Content+Views) 10% 0
Follow-Follower 0
s2*(Income) 5% 0

Count
Followers 0
Login Register as User

Angular Firebase einzelne Node / Subnode ausgeben

07.01.2021 (👁4361)

Angular Firebase einzelne Node ausgeben

 

 

Notizbuch

 - Notiz1

   - Beschreibung:  "erst mal was überlegen, dann notiern.notierne"

   - Titel:  "Wie erstellt man eine Notiz"

 

1) 

Code für Ausgabe in der .html Seite

 

In der app.component.html

Mit | Async und ?.Element 

Bedeutung von ? Fragezeichen hinter (firebase-node | async)?.subnote

Wichtig: das ? bedeutet, dass auf den Asynchronen Wert solange gewartet wird, bis er ausgeben werden kann.

 

{{ (notiz1 |async )?.Titel }}

 

 

App.component.html Code

 

<h1>{{title}}</h1>

<ul>

    <li *ngFor="let item of aufgaben | async">

        {{ item }}

    </li>

</ul>

{{ (notiz1 |async )?.Titel }}

 

 

2) 

Code für Ausgabe in der .html Seite

 

Hier wird die Variable als Observable deklariert

 

public notiz1 :Observable<any>;

 

 

Und mit .list(node).valueschanges() abgeholt

 

this.notiz1=this.afDb.object("/Notizbuch/Notiz1").valueChanges();

 

 

 

App.component.ts Code

 

import { Component } from '@angular/core';

import { AngularFireDatabase,AngularFireList }  from 'angularfire2/database';

import { Observable } from 'rxjs';

@Component({

  selector: 'app-root',

  templateUrl: './app.component.html',

  styleUrls: ['./app.component.css']

})

export class AppComponent {

  //--< Daten >--

  title = 'dailycheck';

  public aufgaben : Observable<any>;

  public notiz1 :Observable<any>;

  constructorprivate afDb:AngularFireDatabase ) {

  }

  ngOnInit()

  {

    this.aufgaben = this.afDb.list('Aufgaben').valueChanges();

    this.notiz1=this.afDb.object("/Notizbuch/Notiz1").valueChanges();

  }

}