From e6401a0365718d71a0a30fb0a92b7c2eb2a99a67 Mon Sep 17 00:00:00 2001 From: XCoder80 Date: Sun, 15 May 2016 09:04:12 -0400 Subject: [PATCH] Fixes scope.init() undefined issue Put pull request back in --- src/toastr.js | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/toastr.js b/src/toastr.js index e3014f9..f80c61c 100644 --- a/src/toastr.js +++ b/src/toastr.js @@ -4,9 +4,9 @@ angular.module('toastr', []) .factory('toastr', toastr); - toastr.$inject = ['$animate', '$injector', '$document', '$rootScope', '$sce', 'toastrConfig', '$q']; + toastr.$inject = ['$animate', '$injector', '$document', '$rootScope', '$sce', 'toastrConfig', '$q', '$timeout']; - function toastr($animate, $injector, $document, $rootScope, $sce, toastrConfig, $q) { + function toastr($animate, $injector, $document, $rootScope, $sce, toastrConfig, $q, $timeout) { var container; var index = 0; var toasts = []; @@ -170,12 +170,16 @@ newToast.isOpened = true; if (options.newestOnTop) { $animate.enter(newToast.el, container).then(function() { - newToast.scope.init(); + $timeout(funtion(){ + newToast.scope.init(); + }); }); } else { var sibling = container[0].lastChild ? angular.element(container[0].lastChild) : null; $animate.enter(newToast.el, container, sibling).then(function() { - newToast.scope.init(); + $timeout(funtion(){ + newToast.scope.init(); + }); }); } });