2015-03-02 67 views

回答

3

如果我的问题是正确的,可以将img标签绑定到角网格作为单元格模板。我为你创建了一个Plunker。检查它http://plnkr.co/edit/YIBa7np3kjip2Zzx7nBB?p=preview

var app = angular.module('app', ['ngTouch', 'ui.grid', 'ui.grid.edit']); 

app.controller('MainCtrl', ['$scope','$sce', function ($scope,$sce) { 



$scope.img="<img ng-src={{url}} />"; 
$scope.img="<img src='https://angularjs.org/img/AngularJS-large.png' />"; 
$scope.gridOptions = { 
     enableSorting: true, 
     columnDefs: [ 
      { name:'firstName', field: 'first-name' }, 
      { name:'1stFriend', field: 'lastName' }, 
      { name:'city', field: 'company'}, 
      { name:'getZip', field: 'employed', enableCellEdit:true}, 
      { name:'Photo', field:'photoP' ,cellTemplate:"<img src='https://angularjs.org/img/AngularJS-large.png' />"} 
     ], 
     data : [ 
      { 
       "first-name": "Cox", 
       "lastName": "Carney", 
       "company": "Enormo", 
       "employed": true, 
       "photoP":"" 
      }, 
      { 
       "first-name": "Lorraine", 
       "lastName": "Wise", 
       "company": "Comveyer", 
       "employed": false, 
       "photoP":"" 
      }, 
      { 
       "first-name": "Nancy", 
       "lastName": "Waters", 
       "company": "Fuelton", 
       "employed": false, 
       "photoP":"" 
      } 
     ] 
     }; 

}]); 
+0

谢谢。有效。 – Dips 2015-03-02 13:45:31