简体   繁体   English

UI-grid net :: ERR_INVALID_URL,同时基于COL_FIELD有条件地显示base64图像

[英]UI-grid net::ERR_INVALID_URL while displaying base64 image conditionally based on COL_FIELD

I am using ui-grid to display a table in which I am showing avatar as the first column. 我正在使用ui-grid显示一个表格,其中将头像显示为第一列。 The avatar image is base64 image displayed conditionally as per col_field value from the back-end. 化身图像是根据后端的col_field值有条件显示的base64图像。

If the col_field is null then display the default image which is in base64 (available in the scope) else the image from the col_field itself. 如果col_field为null,则显示默认图像,该图像位于base64(在范围内可用)中,否则显示来自col_field本身的图像。

issue : 问题

The default image is available in the scope and its displayed correctly but I get the console error net::ERR_INVALID_URL 默认图像在范围内可用,并且可以正确显示,但是出现控制台错误net::ERR_INVALID_URL

error : 错误

data:image/jpg;base64,{{COL_FIELD!=null ? data:image / jpg; base64,{{COL_FIELD!= null? COL_FIELD : 'iVBORw0KGgoAAAANSUhE…NqS+jMdu/p7D8dz14x323NdD+uW/+WonqAL75HX/wswAH3/1hmUDbAiAAAAAElFTkSuQmCC'}} net::ERR_INVALID_URL COL_FIELD:“ iVBORw0KGgoAAAANSUhE…NqS + jMdu / p7D8dz14x323NdD + uW / + WonqAL75HX / wswAH3 / 1hmUDbAiAAAAAElFTkSuQmCC'}} net :: ERR_INVALID_URL

here is the code snippet 这是代码片段

columnDefs : [
{
    field : 'profilImage',
    cellTemplate : '<div class="thumbnail-image-list" > \
                    <img 
                         style="vertical-align:middle;" 
                         width="16" height="16" 
                         alt="{{row.entity.name}}"
                         src="data:image/jpg;base64,{{COL_FIELD!=null ? COL_FIELD : \'' + $scope.defaultImageHexCode + '\'}}"/>
                   </div>',
},

由于您正在使用插值,因此请使用ng-src而不是src绑定属性。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM