my ngmodel does not reload, the binding is not working

后端 未结 1 1087
温柔的废话
温柔的废话 2021-01-24 21:41

Actually this code is from ionic, and I am processing an image that I get through the photo capture. everything works fine, I get the blob, but for some reason my image is not s

1条回答
  •  被撕碎了的回忆
    2021-01-24 22:16

    You can wrap the code in NgZone.run to make sure that it runs in the Angular zone and that the change is picked up by change detection:

    import { NgZone } from '@angular/core';
    
    constructor(private ngZone: NgZone) { }
    
    readFile(file: any) {
      ...
      this.ngZone.run(() => {
        this.myblob = URL.createObjectURL(imgBlob);
      });
      ...
    }
    

    0 讨论(0)
提交回复
热议问题