Closed phillipsnick closed 9 years ago
Some potential working code copied from a website earlier
return alertService = { add: function(type, msg, timeout) { $rootScope.alerts.push({ type: type, msg: msg, close: function() { return alertService.closeAlert(this); } }); if (timeout) { $timeout(function(){ alertService.closeAlert(this); }, timeout); } }, closeAlert: function(alert) { return this.closeAlertIdx($rootScope.alerts.indexOf(alert)); }, closeAlertIdx: function(index) { return $rootScope.alerts.splice(index, 1); } };
Testing timeouts... http://stackoverflow.com/questions/17418716/unit-testing-angular-service-that-uses-timeout-with-jasmines-mock-clock
Some potential working code copied from a website earlier