在推入数组值之后不是在成功

时间:2017-05-09 09:55:22

标签: angular typescript

我将一些数据推送到数组datax:any = [];但是在setInterval之后,这些值不在铆钉内。

这里有什么问题?

ngAfterViewInit(){
    let datax:any = [1,5];

    console.log(datax);//here the data is within clinch

    setInterval(()=> {
        // let random = Math.round(Math.random() * 50) + 1;
        let test = [1,10, 20, 2, 14];

        for(let x of test){
            datax.push(x);
        }

        console.log(datax); //here the data is not within clinch
    },4000);

    console.log(datax); //here I am getting not data. It is empty but I will need it
}

0 个答案:

没有答案