Angular 2 runOutsideAngular still change the UI

前端 未结 5 1315
迷失自我
迷失自我 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:41

    [In short] you need to change one line in your current code

    onClick() {
        this._ngZone.runOutsideAngular(() => {
            setTimeout(()=>this.num = 2,0); // instead of this.num = 2;
        }}));
      }
    

    now if you click the on the

提交回复
热议问题