I am very new to angularjs and i am not sure if this is the right approact I am trying do similar math so I was thinking of putting it in directive
myApp.directive('getDistance',function(Auth){
var R = 6371;
return {
restrict: 'AE',
template: '{{distance}}',
scope: {
value: '=value',
maxValue: '=max-value'
},
link : function(scope, element, attr) {
$scope.$apply(function(){
$scope.distance = scope.maxValue - scope.value;
});
}
};
});
Same directive will be used in the same page multiple times and I think every directive will use the same distance. How can i fix this or what will be a better approach?