Converting List<string[]> for use in ng-repeat

时间:2017-12-08 15:37:45

标签: c# arrays list

So Im a bit stuck on where to go with this. Im handling the upload of csv data.

If the data has 10 columns I am to filter out any columns which are not previous defined in the database. So far so good....

I end up with List<String[]> which looks something like this, where each array is a column of data.

["key", "11111", "222222", "33333", "44444", "55555", "66666", "777777"]

["Group", "9852", "9852", "9852", "9852", "9852", "9852", "9852", "9852", "9852", "9852"]

["Types"Group", "Group", "Group", "Group", "Group", "Group", "Group", "Group", "Group"]

["Price", "0.625711406", "5.631402651", "3.441412731", "4.692835542", "6.014119336", "16.64599505"]

How do I convert a List<String[]> so the first entry of every array would be a whole record as below, without knowing the number of columns

[{"11111", "9852", "Group", "0.625711406"},
{"222222", "9852", "Group", "0.62571140"}] etc

I would be grateful for any ideas

1 个答案:

答案 0 :(得分:0)

这个问题太宽泛了,但我会提供一些技巧来帮助您入门。看看this article

  1. 以HTML格式定义表格。 ng-repeat可用于tr s:

  2. 编写代码以从服务器执行数据提取(Web.API或类似)

    $http({  
            url: "endpoint",  
            dataType: 'json',  
            method: 'GET',  
            data: '',  
            headers: {  
                "Content-Type": "application/json"  
            }  
        }).success(function (response) {  
            debugger;  
            $scope.entityList = response;  
        })  
           .error(function (error) {  
               // error handling here
           });  
    
  3. 编写API代码(基本上是应该处理来自AngularJS的调用的控制器操作)。

  4. 注意:本文中提供的代码只是为了让您入门,您应该重构应用程序,以便在控制器操作代码和数据获取代码(精简控制器)之间进行明确分离。