Search code examples
angularjsangular-ui-gridui-grid

ui grid 400 error in chrome dev tools when loading image in celltemplate


Has anyone seen this problem and know what's going on? If you load this with chrome dev tools open you will see a 400 error ( Bad Request ) http://plnkr.co/edit/fRhBgC4SmPYL8udb007y?p=preview

The problem appears when you use an row.entity.imgurl inside the cellTemplate.

var testApp = angular.module('testApp', ['ui.grid']);

testApp.controller('TestCtrl', function($scope) {

  $scope.grid = {
    rowHeight: 50,
    data: [{
      name: 'Test',
      label: 'Suwako Moriya',
      imgurl: 'http://i.imgur.com/945LPEw.png'
    }],
    columnDefs: [
          { field: 'name'},
          { field: 'label', displayName: 'Name',
            cellTemplate: '<div class="ui-grid-cell-contents" title="TOOLTIP"><img  alt="{{COL_FIELD CUSTOM_FILTERS}}"  src="{{row.entity.imgurl}}"/>'
          }
    ]};
});

Solution

  • You can use:

    ng-src="{{row.entity.imgurl}}"