Let's say I have a method that returns the percentage from two numbers:
calculatePercentage(a, b) {
return (((a - b) / b) * 100 * 2).toFixed(2);
}
Currently, I have this method on component controller. How do I make it reusable across multiple components? What is the best practice?
I am thinking to use it as a service: is that the right way to do it in Angular?