Skip to content
Related Articles

Related Articles

Improve Article

AngularJS | angular.forEach() Function

  • Last Updated : 22 Apr, 2019

The angular.forEach() Function in AngularJS is used to iterate through each item in an array or object. It works similar to the for loop and this loop contains all properties of an object in key-value pairs of an object.


angular.forEach(object, iterator, [context])

Parameter Values:

  • object: It refers to the object to be iterated.
  • iterator: It refers to the iterator function(value, key, obj).
  • context: This is optional. It refers to the object which becomes context for iterator function.


        <script src=
    <body ng-app="app" ng-cloak style="padding:30px">
    <h1 style="color:green">GeeksforGeeks</h1>
    <p>Searching techniques:</p>
    <div ng-controller="geek">
        <div ng-repeat="name in names">
        var app = angular.module("app", []);
        app.controller('geek', ['$scope', function ($scope) {
            $scope.names = [];
            var values = [
            {name: 'Binary Search'},
            {name: 'Linear Search'},
            {name: 'Interpolation Search'}
            angular.forEach(values, function (value, key) {


My Personal Notes arrow_drop_up
Recommended Articles
Page :