Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/413.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_Arrays_Json_Angularjs - Fatal编程技术网

Javascript 在angularjs中的另一个数组中调用json数组

Javascript 在angularjs中的另一个数组中调用json数组,javascript,arrays,json,angularjs,Javascript,Arrays,Json,Angularjs,我在angular和json方面是新手,所以如果有人能帮助我的话 我有一个json数组,其中有用户和买家的姓名。 Json: [ { "name":"Kakaro", "sallers":[ {"sellername":"Naruto","payment":"250","date":"07\/07\/2014","receipt":"popup"}, {"sellername":"Sasuka","payment":"502","date":"08\/07

我在angular和json方面是新手,所以如果有人能帮助我的话

我有一个json数组,其中有用户和买家的姓名。

Json:

[
  {
    "name":"Kakaro",
    "sallers":[
     {"sellername":"Naruto","payment":"250","date":"07\/07\/2014","receipt":"popup"},
     {"sellername":"Sasuka","payment":"502","date":"08\/07\/2014","receipt":"popup"}
    ]
  },
  {
    "name":"Collin Ferall",
    "sallers":[
      {"sellername":"Jonny deep","payment":"250","date":"07\/07\/2014","receipt":"popup"},
      {"sellername":"Brad Pitt","payment":"502","date":"08\/07\/2014","receipt":"popup"}
    ]
  }
]
我想做的是:当我们选择用户时,用户的卖家数据就会出现在表中

我见过很多解决方案,但我在所有解决方案中都失败了。现在我才刚开始

问题:我不知道如何正确调用另一个数组中的数组

html:

<div id="main" class="row" ng-controller='payment'>
  <div>
    <label>Client Name:</label><br/>
    <select class="form-control input-sm" name="client_name">
      <option ng-repeat="names in name" value="{{names.name}}" ng-model="select">{{names.name}}</option>
    </select>
  </div>
  <div id="seller" class="margins_top">
    <table class="table table-bordered">
      <thead>
        <tr>
          <td>Seller Name</td>
          <td>Payment</td>
          <td>Date</td>
          <td>Payment Receipt</td>
        </tr>
      </thead>
      <tbody>
        <tr ng-repeat="sellers in seller">
          <td>{{sellers.sellername}}</td>
          <td>{{sellers.payment}}</td>
          <td>{{sellers.date}}</td>
          <td>{{sellers.receipt}}</td>
        </tr>
      </tbody>
    </table>
  </div><!-- /#seller -->
</div>  
var app = angular.module('payment', []);


app.controller('payment',function($scope,$http){
  getrecord(); // Load all available tasks 
  function getrecord(){  
    $http.post("angular/ajax/payment.php").success(function(data){
      $scope.name = data;
      $scope.seller = data[0].sallers;
    });
  }
});
我创造了小提琴,但它没有使用,但我仍然添加它

像这样试试看

在HTML中

    <select class="form-control input-sm" name="client_name" ng-model="select">
  <option ng-repeat="names in name" value="{{names.name}}">  {{names.name}}</option>
</select>

您能告诉我如何在NewValues中调用“sallers”吗?我已尝试使用数据[0];但它只是显示第一个用户的数据!
$scope.$watch('select', function(newvalue) {
            angular.forEach($scope.name, function(value, key) {
                if(value.name == newvalue) {
                $scope.seller = value.sallers;
                }
            });
            });