Open In App
Related Articles

AngularJS angular.forEach() Function

Improve Article
Save Article
Like Article

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 the context for the iterator function.


Example: This example describes the basic usage of the forEach() function in AngularJS.


<!DOCTYPE html>
    <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) {



Whether you're preparing for your first job interview or aiming to upskill in this ever-evolving tech landscape, GeeksforGeeks Courses are your key to success. We provide top-quality content at affordable prices, all geared towards accelerating your growth in a time-bound manner. Join the millions we've already empowered, and we're here to do the same for you. Don't miss out - check it out now!

Last Updated : 14 Feb, 2023
Like Article
Save Article
Similar Reads
Complete Tutorials