Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/angularjs/24.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 使用AngularJS打印JSON值_Javascript_Angularjs_Json - Fatal编程技术网

Javascript 使用AngularJS打印JSON值

Javascript 使用AngularJS打印JSON值,javascript,angularjs,json,Javascript,Angularjs,Json,我正在尝试使用AngularJS从JSON端点打印一些数据。 终点:-http://localhost:8081/api JSON结构:- { "1": { "venture": "XYZ Informatics", "member": [ { "name": "abcd", "email": "abcd@gmail.com" } ], "message": "This is good day",

我正在尝试使用AngularJS从JSON端点打印一些数据。 终点:-
http://localhost:8081/api

JSON结构:-

{
  "1": {
    "venture": "XYZ Informatics",
    "member": [
      {
        "name": "abcd",
        "email": "abcd@gmail.com"
      }
    ],
    "message": "This is good day",
    "isclicked": false
  },
  "2": {
    "venture": "BBC Informatics",
    "member": [
      {
        "name": "xyz",
        "email": "xyz@gmail.com"
      }
    ],
    "message": "This is bad day",
    "isclicked": false
  }
}
我想在第行显示venture s的名称。我的第行预期输出为:-

XYZ Informatics
BBC Informatics
我的密码是:-

    <!DOCTYPE html>
<html ng-app="MyApp">
  <head>
    <link rel="stylesheet" href="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css">
    <script src="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/js/bootstrap.min.js"></script>
    <script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.4.7/angular.min.js"></script>
    <style>
      table, th, td {
      border: 1px solid black;
      border-collapse: collapse;
      }
      th, td {
      padding: 15px;
      }
    </style>
  </head>
  <body>
    <div ng-app="MyApp" ng-controller="displayController">
      <table style="width:100%">
        <tr ng-repeat="data in datas">
          <td>{{ data.venture }}</td>
        </tr>
      </table>
    </div>
    <script>
      angular.module('MyApp', [])
      .controller('displayController', function($scope, $http) {
      var url = "http://localhost:8081/api";
      $http.get(url).success(function (response) {
      $scope.datas = response;
      });
      }
    </script>
  </body>
</html>

表,th,td{
边框:1px纯黑;
边界塌陷:塌陷;
}
th,td{
填充:15px;
}
{{data.venture}
angular.module('MyApp',[])
.controller('displayController',函数($scope,$http){
变量url=”http://localhost:8081/api";
$http.get(url).success(函数(响应){
$scope.datas=响应;
});
}

但是没有显示该值。可能我没有进入每个JSON数组。

脚本中有语法错误。请关闭控制器的括号

  <script>
    angular.module('MyApp', [])
      .controller('displayController', function($scope, $http) {
        //changed to your local api
         var url = "http://localhost:8081/api";
        $http.get(url).success(function(response) {
          $scope.datas = response;
        });
      });//this is the place where you miss out the closing bracket
  </script>

angular.module('MyApp',[])
.controller('displayController',函数($scope,$http){
//已更改为本地api
变量url=”http://localhost:8081/api";
$http.get(url).success(函数(响应){
$scope.datas=响应;
});
});//这是你错过结束括号的地方
这是工作表