2016-08-09 1 views
0

여기로드 된 객체 'result'로고 필드를 이미지 이름으로 표시하고 싶습니다. 어떻게 동적으로이 작업을 수행 할 수 있습니까? 그림과 같이json 개체에서 이미지를로드하고 각도 ui 격자에 표시 할 수 있습니다.

angular.module('myApp').controller('homecon', function ($scope, $http, $location, $rootScope) { 


$http.get("http://localhost:1488/api/CompanyApi/get").success(function (res) { 
    $rootScope.result = res; 

    }); 



    $scope.myGrid = { 


     data: 'result', 



     columnDefs: [{ field: "Comp_Name", displayName: 'Cmpany' }, 
      { field: 'email', displayName: 'Email' }, 
       { field: 'logo', cellTemplate: "<img width=\"50px\" ng-src='/logos/{{result[1].logo}}' lazy-src>" } 
     ] 

    }; 

output for code display one image i want to display all images related with its object

답변

0

내가 당신의 결과 내부에 어떤 데이터를 모르지만이

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

app.controller('MainCtrl', ['$scope', '$http', function ($scope, $http) { 
    $scope.gridOptions = { 
    enableSorting: true, 
    rowHeight:100, 
    columnDefs: [ 
     { field: 'name' }, 
     { field: 'company' }, 
     { field: 'image', cellTemplate:"<img width=\"50px\" ng-src=\"{{grid.getCellValue(row, col)}}\" lazy-src>"} 
    ], 
    data:[ 
     {name:"Name1",company:"Company1",image:"http://cdn.flaticon.com/png/256/70689.png"}, 
     {name:"Name2",company:"Company2",image:"http://cdn.flaticon.com/png/256/70689.png"}, 
     {name:"Name3",company:"Company3",image:"http://cdn.flaticon.com/png/256/70689.png"} 
     ] 
    }; 

}]) 
처럼 뭔가를 시도 할 수 있습니다
관련 문제