提取信息

问题描述:

所以我有我的控制器,它有一个名字,豆类列表和操作的列表下列对象:提取信息

{ 
    "name": "Charge", 
    "beans": [ 

    ], 
    "operations": [ 
    { 
     "name": "getSize", 
     "returnType": "java.lang.Integer", 
     "description": "empty description", 
     "parameters": [ 

     ] 
    }, 
    { 
     "name": "truncate", 
     "returnType": "java.lang.Void", 
     "description": "empty description", 
     "parameters": [ 

     ] 
    }, 
    { 
     "name": "count", 
     "returnType": "java.lang.Integer", 
     "description": "empty description", 
     "parameters": [ 
     { 
      "name": "javaCode", 
      "type": "java.lang.String", 
      "value": null 
     } 
     ] 
    }, 
    { 
     "name": "update", 
     "returnType": "java.lang.Integer", 
     "description": "empty description", 
     "parameters": [ 
     { 
      "name": "javaSelectCode", 
      "type": "java.lang.String", 
      "value": null 
     }, 
     { 
      "name": "javaUpdateCode", 
      "type": "java.lang.String", 
      "value": null 
     } 
     ] 
    }, 
    { 
     "name": "delete", 
     "returnType": "java.lang.Integer", 
     "description": "empty description", 
     "parameters": [ 
     { 
      "name": "javaCode", 
      "type": "java.lang.String", 
      "value": null 
     } 
     ] 
    }, 
    { 
     "name": "dump", 
     "returnType": "java.lang.Void", 
     "description": "empty description", 
     "parameters": [ 
     { 
      "name": "javaSelectCode", 
      "type": "java.lang.String", 
      "value": null 
     }, 
     { 
      "name": "destinationPath", 
      "type": "java.lang.String", 
      "value": null 
     } 
     ] 
    }, 
    { 
     "name": "select", 
     "returnType": "java.lang.String", 
     "description": "empty description", 
     "parameters": [ 
     { 
      "name": "javaCode", 
      "type": "java.lang.String", 
      "value": null 
     } 
     ] 
    } 
    ], 
    "$$hashKey": "object:620" 
} 

基本上,我想从这个对象显示所有操作在下拉菜单中。

所以我在想有什么样的:

<div ng-repeat="operation in object.operations"> 
    {{operation.name}} 
</div> 

除了上面的代码不会显示任何屏幕上,在控制台中没有错误,没有什么。

任何帮助将不胜感激!

编辑:

的Javascript服务:

app.controller('selectAll', ['$http', '$scope' , '$rootScope', function ($http, $scope, $rootScope) { 

    $scope.response; 
    $scope.operations; 

    $rootScope.$on("invokeSelectAll", function(){ 
     $scope.invokeSelectAll(); 
    }); 

    $scope.invokeSelectAll = function(){ 
     $scope.response = $http.post('/invoke/selectAll/', $rootScope.dataObj); 
     $scope.object = JSON.stringify($rootScope.object); 
     console.log(" object operation from selectAll " + $scope.object); 
     $scope.response.then(function(data) { 
      $scope.responses = data.data ? data.data : "Select Operation not supported on this bean"; 
     }); 
    } 
}]); 

,开发者控制台的屏幕截图: https://imgur.com/a/8WAAL

+1

尝试使用* ngFor –

+2

这对角或AngularJS?我有一种感觉,你已经使用了错误的标签 –

+0

我使用的是角度为1.6的 –

使用JSON.stringify()创建从JavaScript对象的JSON字符串。使用JSON.parse()将JSON字符串解析为JavaScript对象。

在你的情况下,你需要使用JSON.parse(),因为你从服务器得到一个JSON字符串并且想把它解析成一个JavaScript对象。

$scope.object = JSON.parse($rootScope.object); 

你透过JSON.stringify它是用来javascript对象更改为字符串,并将其存储为唯一的字符串。

您应该使用JSON.parse()解析数据,并将数据变为JavaScript对象。你可以在ng-repeat中轻松使用它。

试试吧,它会正常工作