HTML Sample Code:
<!DOCTYPE html>
<html ng-app="">
<head>
<script SRC="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.13/angular.js">
</script>
</head>
<body>
<fieldset>
<legend>ForEach Function in angular JS</legend>
<script>
var peopleList = [{name: 'Ashish', gender: 'male'},{name: 'Vikram', gender: 'male'},{name: 'Geetha', gender: 'Female'}];
document.write("To display Name:</br>");
angular.forEach(peopleList, function(value, key) {
document.write(value.name);
document.write("</br>");
});
document.write("To display Gender:</br>");
angular.forEach(peopleList, function(value, key) {
document.write(value.gender);
document.write("</br>");
});
</script>
</fieldset>
</body>
</html>
Output:
<!DOCTYPE html>
<html ng-app="">
<head>
<script SRC="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.13/angular.js">
</script>
</head>
<body>
<fieldset>
<legend>ForEach Function in angular JS</legend>
<script>
var peopleList = [{name: 'Ashish', gender: 'male'},{name: 'Vikram', gender: 'male'},{name: 'Geetha', gender: 'Female'}];
document.write("To display Name:</br>");
angular.forEach(peopleList, function(value, key) {
document.write(value.name);
document.write("</br>");
});
document.write("To display Gender:</br>");
angular.forEach(peopleList, function(value, key) {
document.write(value.gender);
document.write("</br>");
});
</script>
</fieldset>
</body>
</html>
Output:
No comments:
Post a Comment