Hello, I have been experimenting with javascript and I have a question about this:
angular.module('starter.services')
.factory('GameTimerService', function (UtilService) {
var interval = 1000;
function doThisEverySecond(myscope, StopTimer)
{
if (myscope.rangeValue == 60 || myscope.rangeValue > 5) {
try {
MediaService.PlayMedia("sound.mp3");
}
catch (e) {
console.log(e);
}
finally {
StopTimer();
}
}
else {
myscope.rangeValue++;
}
}
function stopTimer() {
UtilService.StopTimer();
}
return {
StartTimer : function(myscope) {
UtilService.StartTimer( function() { doThisEverySecond(myscope, stopTimer); } , interval);
},
StopTimer : function()
{
stopTimer();
},
}
})
It is my angular service and it works great.
But when I change this piece of code:
return {
StartTimer : function(myscope) {
UtilService.StartTimer( function() { doThisEverySecond(myscope, stopTimer); } , interval);
},
StopTimer : function()
{
stopTimer();
},
}
for this:
return {
StartTimer : function(myscope) {
UtilService.StartTimer( function() { doThisEverySecond(myscope, StopTimer); } , interval);
},
StopTimer : function() {
UtilService.StopTimer();
},
}
it no longer works.
My question is why?