为什么我的 ui-grid cellTemplate 图像没有显示?

Why aren't my ui-grid cellTemplate images not displaying?

我正在为 angularjs iTunes 应用程序从 ng-grid 升级到 ui-grid,我在获取相册图片和视图图标时遇到一些困难以显示在我的 ui-grid,它似乎无法绑定到 img 标签。视图图标应链接到 url(见下文)。

在我的$scope.gridOptions...

里面
{field: 'View', displayName: 'View', width: 60, cellTemplate: '<div class="ui-grid-cell-contents ng-binding ng-scope" ng-class="col.colIndex()"><a ng-href="grid.getCellValue(row, col)"><img ng-src="https://images.onlinelabels.com/images/clip-art/emyller/emyller_magnifying_glass.png" height="30px" width="30px" lazy-src /></a></div>'},

{field: 'AlbumArt', displayName: 'Album Cover', width: 110, cellTemplate: '<div class="ui-grid-cell-contents ng-binding ng-scope" ng-class="col.colIndex()"><img ng-src="grid.getCellValue(row, col)" lazy-src /></div>'},

根据自定义模板的UI-Grid Tutorial

You can use grid.appScope in your row template to access elements in your controller's scope

因此您的 cellTemplate 需要调用 grid.appScope.getCellValue(...) 而不是 grid.getCellValue(...)。你的 ng-src 表达式也需要 {{ brackets }} 所以 Angular 计算它。

这是一个基于您的 columnDef 的快速而简单的示例: http://plnkr.co/edit/jGGBx1PlOjUqAq282L7I?p=preview