Users have the ability to select a month by clicking +1 month or -1 month.
Each click triggers a loop based on the number of days in the chosen month.
Within the loop, a function is called to fetch data through an $http request.
The issue at hand is as follows: (for example)
-When the page loads: var data = [];
-Time 1: User clicks on January:
31 $http requests are made, resulting in 15 callbacks.
data.length = 15;
Time 2: User clicks on February.
The variable is reset with var data = []
15 callbacks from the previous month carry over, in addition to 30 callbacks from February.
I am looking for a solution to halt callbacks when the user switches to another month...
For a clearer demonstration, check out this basic Fiddle:
http://jsfiddle.net/36qp9ekL/318/