我有一个包含数据但长度为零的数组。我无法理解这种怪异的性质。希望获得一些帮助。
//Component code
val1=[];
updateData(){
this.val 1 = this.service.getData() // Using Behavior Subject to get the Data from service
console.log(this.val1);// Displays the values
console.log(this.val1.length);//Displays 0
}
checked(event){
console.log(this.val1);// Displays the values
console.log(this.val1.length);//Displays correct length
}
//Service code
getBackendData(){
//call to backend and create a list
this.behaviorSubjectObj.next(List);
}