AngularJS forEach

angularjs example for forEach with object

by Varun Sukheja

HTML

<script src="https://cdnjs.cloudflare.com/ajax/libs/angular.js/1.3.14/angular.min.js"></script>
<div ng-controller='MyController' ng-app="myApp">
    <div>{{title}}</div>
</div>

JavaScript

var app = angular.module('myApp', []);
app.controller('MyController', ['$scope', '$interval', function($scope, $interval) {
    $scope.title = 'Hello world';
    $scope.myObj = {
        Name: "Varun",
        Gender: "male",
        Country: "India",
        City: "Pune"
    }
    angular.forEach($scope.myObj, function(value,key) {
        console.log(key+' : '+value);
    });


}]);