While working on angularJS, I encountered a problem with calculating operations on JSON data. I need assistance in solving this issue. enter code here
Code snippet. In the "script.js" file, there is JSON data named "marksArray". My task is to calculate the total marks per student (for example - abc's total marks are 85) and also determine the count of students (separate count like - abc:2 , pqr:2 , xyz:3). Any help in resolving this problem would be greatly appreciated.
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"}
];
});