美文网首页
angular2出现值变化没有立即更新到ui上

angular2出现值变化没有立即更新到ui上

作者: SevenLonely | 来源:发表于2017-10-22 17:49 被阅读0次

解决方法

import { Component, OnInit,NgZone } from '@angular/core';

@Component({
  selector: 'app-home',
  templateUrl: './home.component.html',
  styleUrls: ['./home.component.scss']
})
export class HomeComponent implements OnInit {

  querys = 2323;

  constructor(private ngzone:NgZone) { }

  ngOnInit() {
  }

  set() { 
    this.ngzone.run(() => { 
      this.querys = 5;
    })
  }

}

相关文章

网友评论

      本文标题:angular2出现值变化没有立即更新到ui上

      本文链接:https://www.haomeiwen.com/subject/qrcnuxtx.html