Javascript 如何在angularjs中迭代$scope变量?

Javascript 如何在angularjs中迭代$scope变量?,javascript,arrays,angularjs,Javascript,Arrays,Angularjs,我有这样的代码: $scope.maps = [ new google.maps.LatLng($scope.longitude[0], $scope.latitude[0]), new google.maps.LatLng($scope.longitude[1], $scope.latitude[1]), new google.maps.LatLng($scope.longitude[2], $scope.latitude[2])]; 如何简化AngularJS样式以

我有这样的代码:

$scope.maps = [
    new google.maps.LatLng($scope.longitude[0], $scope.latitude[0]),
    new google.maps.LatLng($scope.longitude[1], $scope.latitude[1]),
    new google.maps.LatLng($scope.longitude[2], $scope.latitude[2])];
如何简化AngularJS样式以进行更多迭代?

$scope.maps=[];
$scope.longitude.forEach(函数(el,i){
$scope.maps.push(新的google.maps.LatLng(el$scope.latitude[i]);
});
//或
$scope.maps=[];
对于(变量i=0;i<$scope.longitude.length;++i){
$scope.maps.push(新的google.maps.LatLng($scope.longitude[i],$scope.latitude[i]);

}
只是为了澄清编码员的答案。 不是“角度”迭代,他展示的是javascript。您也可以将其用于读取数据,因为您可以在html中使用角度ng repeat


很酷,正如预期的那样。谢谢@CodeiSir