How do I generate nested table in one column if it has list of values using angular js?

前端 未结 2 1989
悲哀的现实
悲哀的现实 2020-12-20 07:46

index.js

var app = angular.module(\'plunker\', []);

app.controller(\'MainCtrl\', function($scope) {
  $scope.name = \'World\';

  $scope.data =[{\"Id\":1,\"         


        
2条回答
  •  既然无缘
    2020-12-20 08:21

    I'm not really sure what you want to render, but this might give you some ideas.

    see: http://plnkr.co/edit/znswagx45a2F7IThdQJn?p=preview

    app.js

    var app = angular.module('plunker', []);
    
    app.controller('MainCtrl', function($scope) {
      $scope.name = 'World';
      $scope.data =[{"Id":1,"Title":"en-US","Description":"UnitedStates","MyValues":[{"Id":100,"Value":"Save"}]},
    {"Id":1,"Title":"en-UK","Description":"UK","MyValues":[{"Id":102,"Value":"Delete"}]}]
      $scope.cols = Object.keys($scope.data[0]);
    
      $scope.notSorted = function(obj){
        if (!obj) {
            return [];
        }
        return Object.keys(obj);
    }  
    });
    

    index.html

    {{value}}
    Id:{{value[0].Id}}
    Value:{{value[0].Value}}
    {{value}}

    If you need to be more general, maybe instead of

    you could do something like
    . I didn't have time to try and get that working though, but something to look into.

提交回复
热议问题