angular.forEach
ng
Invokes the iterator
function once for each item in obj
collection, which can be either an
object or an array. The iterator
function is invoked with iterator(value, key)
, where value
is the value of an object property or an array element and key
is the object property key or
array element index. Specifying a context
for the function is optional.
Note: this function was previously known as angular.foreach
.
var values = {name: 'misko', gender: 'male'}; var log = []; angular.forEach(values, function(value, key){ this.push(key + ': ' + value); }, log); expect(log).toEqual(['name: misko', 'gender:male']);
angular.forEach(obj, iterator[, context]);
Param | Type | Details |
---|---|---|
obj | ObjectArray | Object to iterate over. |
iterator | Function | Iterator function. |
context (optional) | Object | Object to become context ( |
Object|Array | Reference to |