<!DOCTYPE html>
<
html
>
<
head
>
<
title
>
Angular JS Iteration Over Filtered Data
</
title
>
<
link
rel
=
"stylesheet"
href
=
<
script
src
=
</
script
>
<
style
>
body {
text-align: center;
}
h1 {
color: green;
}
ul {
display: inline-block;
text-align: left;
}
</
style
>
</
head
>
<
body
>
<
h1
>GeeksforGeeks</
h1
>
<
h3
>
Iterating the ng-repeat filter
for objects collection in AngularJS
</
h3
>
<
div
ng-app
=
"mainApp"
ng-controller
=
"studentController"
>
<
input
type
=
"text"
ng-model
=
"searchName"
>
<
br
/>
<
ul
>
<
li
ng-repeat="student in students
| filter: searchName as result">
{{ student.name + ', marks:' + student.marks }}
</
li
>
</
ul
>
<
p
><
b
>length of filtered data:</
b
> {{ result.length }}</
p
>
<
button
type
=
"button"
class
=
"btn btn-success"
ng-click
=
"changemarks(result)"
>
change marks
</
button
>
</
div
>
<
script
>
var mainApp = angular.module("mainApp", []);
mainApp.controller('studentController', function ($scope) {
$scope.students = [{
name: 'Aman',
marks: 70
}, {
name: 'Aditya',
marks: 80
}, {
name: 'Pratyush',
marks: 82
}, {
name: 'Prakhar',
marks: 85
}, {
name: 'Pranjal',
marks: 75
}, {
name: 'Sunny',
marks: 69
}];
$scope.changemarks = function (values) {
angular.forEach(values, function (value, key) {
value.marks += 10;
console.log(value.name + ' ' + value.marks);
});
};
});
</
script
>
</
body
>
</
html
>