Angular2 View Not Changing After Data Is Updated

前端 未结 6 1398
长情又很酷
长情又很酷 2020-12-09 15:42

I am trying to update my view after a websocket event returns updated data.

I injected a service into my app and call getData() method on the service. This method em

6条回答
  •  醉梦人生
    2020-12-09 16:15

    A very simple way to do this is just run in zone whatever variable you want to update.

    zone.run(()=>{
        this.variable = this.variable;
    });
    

    Doesn't seem like it can be that easy, but just assigning it to itself will update it if run in zone. I don't know if this is still an issue in angular2 since I'm running a little bit older version.

提交回复
热议问题