数组长度问题

时间:2020-01-29 18:07:54

标签: angular7

我有一个包含数据但长度为零的数组。我无法理解这种怪异的性质。希望获得一些帮助。

       //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);
                          }

0 个答案:

没有答案
相关问题