Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/arrays/12.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
angularjs+;jquery:如何在Foreach循环中访问数组中的数组元素?_Jquery_Arrays_Angularjs - Fatal编程技术网

angularjs+;jquery:如何在Foreach循环中访问数组中的数组元素?

angularjs+;jquery:如何在Foreach循环中访问数组中的数组元素?,jquery,arrays,angularjs,Jquery,Arrays,Angularjs,我有一个对象数组“休假” $scope.Vacations = [{Id:'1' ,VacationType = {TypeId='1' ,TypeName = 'test'}}]; 它只包含一个集合的其他对象数组“VacationType” 我想提取TypeId 我做过这样的事: $scope.selectedVacationType = []; $scope.TypeTd; $scope.selectedVacationType=Vacations.VacationType; $scop

我有一个对象数组“休假”

$scope.Vacations = [{Id:'1' ,VacationType = {TypeId='1' ,TypeName = 'test'}}];
它只包含一个集合的其他对象数组“VacationType”

我想提取TypeId

我做过这样的事:

$scope.selectedVacationType = [];
$scope.TypeTd;

$scope.selectedVacationType=Vacations.VacationType;
$scope.TypeTd;= $scope.selectedVacationType[0].Id;
但这是行不通的


可以做什么?

使用
$scope.selectedVacationType=Vacations[0]。VacationType

Vacations
表示项目列表
[…]

顺便说一句,您的型号错误,请删除
=
并替换为

 $scope.Vacations = [{
        Id: '1',
        VacationType : {
           TypeId : '1',
           TypeName : 'test'
        }
    }];
HTML

selectedVacationType: <pre>{{selectedVacationType|json}}</pre>
TypeTd:               <pre>{{TypeTd|json}}</pre>
TypeName:             <pre>{{TypeName|json}}</pre>
演示

    $scope.Vacations = [{
    Id: '1',
    VacationType : {
    TypeId : '1',
        TypeName : 'test'
    }
}];

$scope.selectedVacationType = $scope.Vacations[0].VacationType;
$scope.TypeTd = $scope.selectedVacationType.TypeId;
$scope.TypeName = $scope.selectedVacationType.TypeName;