When I tried to use a list to store data and display it later, I encountered the following issues:
Using ListOfName.lenth
resulted in [Photo of console][1]. However, using Console.log(ListOfName)
displayed [Photo of List in console][2].
[1]: https://i.sstatic.net/nJ43X.png
[2]: https://i.sstatic.net/EQ0Kk.png
Home Component:
import { Component, Input, OnInit } from '@angular/core';
import {Subject} from "rxjs";
import {FirebaseService} from "../services/firebase.service";
import {JSDocTagName} from "@angular/compiler/src/output/output_ast";
@Component({
selector: 'app-homework',
templateUrl: './homework.component.html',
styleUrls: ['./homework.component.css']
})
export class HomeworkComponent implements OnInit {
constructor( public firebaseservise:FirebaseService) { }
ListOfName:string[] =[]
TempName = `<h1>dasdasd</h1>`
tagName = ``
Temp = 1
GetData(){
this.ListOfName = this.firebaseservise.GetDataFromTestAll(this.ListOfName)
console.log(this.ListOfName.length)
console.log(this.ListOfName)
}
ngOnInit(): void {
}
}
GetDataFromTestAll:
GetDataFromTestAll(Tempe:string[]){
this.ListOfName=[]
this.FirebaseData.database.ref("Test").get().then(res =>{
res.forEach(Groups =>{
if (localStorage.getItem('Group') == Groups.key){
this.FirebaseData.database.ref(`Test/`+Groups.key).get().then(r=>{
r.forEach(l=>{
this.ListOfName.push(String(l.key))
})
})
}
else {
}
})
})
return this.ListOfName
}