Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/ionic-framework/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Angularjs 当图像作为Base64完全加载时,如何显示图像?_Angularjs_Ionic Framework_Ionic2_Ionic3 - Fatal编程技术网

Angularjs 当图像作为Base64完全加载时,如何显示图像?

Angularjs 当图像作为Base64完全加载时,如何显示图像?,angularjs,ionic-framework,ionic2,ionic3,Angularjs,Ionic Framework,Ionic2,Ionic3,我使用Ionic3有以下代码行: <ion-img src="data:image/bmp;base64,{{poline.itemimagedata}}"> 在{{poline.itemimagedata}中,包含base64图像 问题是:在加载视图时,变量可能未填充,但可以稍后填充或更新。在这种情况下,Ionic无法相应地更新图像。有什么好的解决办法吗 填充变量后,是否必须手动更新图像?如果是,怎么做?也许img中甚至有一个不错的加载指示器选项?我通过手动触发更改检测解决了

我使用Ionic3有以下代码行:

<ion-img src="data:image/bmp;base64,{{poline.itemimagedata}}">

{{poline.itemimagedata}
中,包含
base64图像

问题是:在加载视图时,变量可能未填充,但可以稍后填充或更新。在这种情况下,Ionic无法相应地更新图像。有什么好的解决办法吗


填充变量后,是否必须手动更新图像?如果是,怎么做?也许img中甚至有一个不错的加载指示器选项?

我通过手动触发更改检测解决了这个问题:


ChangeDetectorRef.detectChanges()

您是否收到任何错误?没有。如果未加载变量,它只加载一个空白图像(如果图像中填充了内容,则加载该图像),当我将新图像加载到变量中时,它不会更新为新图像。(我想这是我想要的行为,我只是在寻找解决问题的正确方法。)使用指令而不是
src
属性。参见示例。忽略我的第一条评论,我没有注意到您正在使用
ion img
poline.itemimagedata
格式正确吗?您所说的“格式正确”到底是什么意思?它是任何类型的变量。当我重新加载视图或在加载视图时变量已填充时,它会起作用。但它不会实时更新。