This article mainly introduces the format and parameters used by angular. foreach loop method. It is a very basic article and has its own lifecycle with reference to angular. Loop to the variable reset value of an angular listener. It is better to use the loop method that comes with angular.
. "Angular. foreach"
Format:
The Code 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]. );
});
The parameters are as follows:
Objs: set to be traversed
Data: Repeat the current data
Index: The current index
Array: the set to be traversed. The objs is transmitted once every time it passes through.
You do not need to write the following two parameters:
The Code is as follows:
Var objs = [{a: 1}, {a: 2}];
Angular. forEach (objs, function (data ){
Console. log (data. );
});