Actually I was doing some calculation operations on JSON data using angularJS , Can any one please help me in solving this problem . enter code hereCode snippet. If you look at "script.js" file , there is a JSON data "marksArray" , I have to calculate total marks per student (For Example - abc's total marks is 85) and also have to count how many students are there (separate count like - abc:2 , pqr:2 , xyz:3). Please help me to solve this problem.
Html:
<!DOCTYPE html>
<html>
<head>
<link rel="stylesheet" href="style.css" />
<script src="script.js"></script>
</head>
<body ng-app="myapp">
<div ng-controller="mainController">
<label for="repeatSelect1"> Field 2: </label>
<select name="repeatSelect1" id="repeatSelect1" ng-model="data.repeatSelect1">
<option ng-repeat="(key, val) in marksArray[0]" value="{{val}}">{{key}}</option>
</select>
<br />
<strong>Selected student:</strong>
<br />
<textarea>{{chosen | json}}</textarea>
<br />
<br />
</div>
</body>
</html>
Javascript
angular.module('myapp')
.controller("mainController", function ($scope){
$scope.marksArray = [
{name: "abc", Marks: "50"},
{name: "xyz", Marks: "44"},
{name: "abc", Marks: "35"},
{name: "xyz", Marks: "55"},
{name: "pqr", Marks: "67"},
{name: "xyz", Marks: "65"},
{name: "pqr", Marks: "45"}
];
});