Angular 2 runOutsideAngular still change the UI

前端 未结 5 1349
迷失自我
迷失自我 2020-12-01 11:12

From my understanding of runOutsideAngular(), if I need to run something that won\'t trigger the Angular change detection, I need to use this function. My code is not workin

5条回答
  •  盖世英雄少女心
    2020-12-01 11:47

    ...
    constructor(
            private ngZone: NgZone
    ){
        ngZone.runOutsideAngular(() => {
            setInterval(()=>{
                this.num= new Date().Format('yyyy-MM-dd HH:mm:ss');
            },1000);
        });
    }
    ...
    

提交回复
热议问题