In my question I want to display values of 4 entities (I am getting those values from server side in milliseconds) in minutes. I can easily do using a custom filter. But I want to display this using a function, not a custom filter
itemTypes is the global variable where I am storing all parameter of all my items. I am getting all my data from a webservice in this global variable.
Now my code
$scope.itemTypes = itemTypes; // itemTypes is a global variable
$scope.selectedItem = {}; // In this variable I am storing all parameters of one particular item type.
if(selectedItemIndex > -1){
$scope.selectedItem = $scope.itemTypes[selectedItemIndex];
}
Now this $scope.selectedItem have 10 parameters whenever a partular iem type is selected.
4 of those parameters are in milliseconds, I need to display those 4 in minutes
I don't want to use a filter, instead I want to use a function called getTimeInMinute
I want to display only in minutes , not in seconds
This is my function
$scope.getTimeInMinute = function(timeInMilli){
var ms = timeInMilli;
ms = 1000*Math.round(ms/1000); // round to nearest second
var d = new Date(ms);
//console.log(d.getUTCMinutes());
var x = d.getUTCMinutes()
return x;
}
I got this function from this Stackoverflow question (link provided) Link 1
In my template I want to display like this
<div>{{getTimeInMinute(selectedItem.parameter1)}}</div>
<div>{{getTimeInMinute(selectedItem.parameter2)}}</div>
<div>{{getTimeInMinute(selectedItem.parameter3)}}</div>
<div>{{getTimeInMinute(selectedItem.parameter4)}}</div>
I am unable to display the data in milliseconds using function. I can easily do using a custom filter. But I want to display this using a function, not a custom filter