angular has its own life cycle. When looping to a complex value of an angular listener. It is best to use the angular's own loop method . “angular.foreach”
Format:
The code copy is as follows:
var objs =[{a:1},{a:2}];
angular.forEach(objs, function(data,index,array){
//data is equivalent to array[index]
console.log(data.a+'='+array[index].a);
});
The parameters are as follows:
objs: Collections that need to be traversed
data: the current data when traversing
index: The current index is traversed
array: A collection that needs to be traversed. Objs will be passed as it is once every time iterates.
You can also not write the following two parameters:
The code copy is as follows:
var objs =[{a:1},{a:2}];
angular.forEach(objs, function(data){
console.log(data.a);
});