0
我完全是新的角JS,請告訴我如何能夠顯示圖像作爲我的網格中使用角JS的一些列的值。如何使用角度js ng-grid在網格列之一中顯示圖像?
我完全是新的角JS,請告訴我如何能夠顯示圖像作爲我的網格中使用角JS的一些列的值。如何使用角度js ng-grid在網格列之一中顯示圖像?
如果我的問題是正確的,可以將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":""
}
]
};
}]);
謝謝。有效。 – Dips 2015-03-02 13:45:31
你可以顯示你到目前爲止的代碼嗎? – GHC 2015-03-02 12:00:06