SoFunction
Updated on 2025-04-12

2 ways to do data traversal in angularJs

The two methods are:

1. Array data traversal

2. Object data traversal

<!doctype html>
<html lang="en">
<head>
 <meta charset="UTF-8">
 <script src=""></script>
</head>
<body>
<div ng-app="module" ng-controller="ctrl">
{{data}}
</div>
<script>
 var m = ('module', []);
 ('ctrl', ['$scope', function ($scope) {
  $=[{name: 'Lingling on the road', url: ''},{name: 'Like as cold as water', url: ''}]
  //Array data traversal  ($, function (v, k) {
    = 'www.'+;
   (v);//Read all array data   (k);//Read all objects' subscript  });

  //Object data traversal  data ={name: 'Lingling on the road', url: ''};
  (data, function (v, k) {
    = 'www.'+;
   (v);//Get the value of the object, that is, Lingling is on the road and   (k);//Get the object subscript name and url
  });
 }]);
</script>
</body>
</html>

The above two methods of data traversal in angularJs are all the content I share with you. I hope you can give you a reference and I hope you can support me more.