firebase에서받는 간단한 데이터가 있지만 해당 데이터에서 필터가 작동하지 않습니다. 많은 게시물을 검색했지만 도움이되지 않습니다. 누락 된 항목이 무엇입니까? 모든 도움을필터가 각도로 작동하지 않습니까?
나는 그것의 내부 OnInit() 경우 같은 데이터를 얻을 수 있습니다.
export class SignUpComponent implements OnInit {
ngOnInit() {
const someEvemnts = [
{type: 'attack', value: 1, target: 'dorkman'},
{type: 'yaeed', value: 2, target: 'dorkman'},
{type: 'attack', value: 3, target: 'fluffy'},
{type: 'attack', value: 4, target: 'dorkman'},
]
const total = someEvemnts
.filter(event => event.type== 'attack')
.filter(event => event.target== 'dorkman')
console.log(total); // works fine
let check = this.values; // works fine
let check2 = this.values.filter(val => val) // not works
console.log(check);
console.log(check2); // returns empty
this.SignIn();
}
SignIn(){
firebase.database().ref('/companies').on('child_added', (data)=>{
this.values.push(data.val())
}
)
}
values=[];
}
콘솔 :
은 아래에있는 내 코드입니다.
이 acheive하려고하지만 –
변수 네가 원하는 필터를 expectd이로 그 작동하지 이잖아? 데이터에 부울이 없습니다. 귀하의 코드는 필터링 할 수없는 전체 객체를 필터링하므로 아무 것도 반환하지 않습니다. – CodeNashor
let check2 = this.values.filter (val => val.name == 'shanth') –