I'm currently working on a straightforward AngularJS project, and here's the code I have so far:
This is my view:
<tr ng-repeat="metering in meterings">
<td>1</td>
<td>{{metering.d.SerialNumber}}</td>
</tr>
This is my controller:
angular.module('MainCtrl', []).controller('MainController', function($scope,$http,Nerds) {
Nerds.get()
.success(function(data){
$scope.meterings = data;
});
});
This is my services:
angular.module('NerdService', []).factory('Nerds', ['$http', function($http) {
return{
get : function(){
return $http.get('http://amrse.net/list.json'); //Let's pretend that this path is works fine
}
}
}]);
My questions are: 1. How can I make the number dynamically change in this table (in the view)? <td>1</td>
- I would like to calculate the total of the array that is repeated in
. Something like:<td>{{metering.d.SerialNumber}}</td>
. How can I achieve that?Total : {{ metering.getTotal() }}