2016-11-24 3 views
-1

Я пытаюсь использовать Toastr с angular js, но получает следующую ошибку. Я включил jqery.js файл, как ожидалось.Toastr не работает с angularjs

src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js" 

Сообщение об ошибке:

angular.js:11594 TypeError: Cannot read property 'extend' of undefined 
at m (toastr.js:474) 
at Object.o [as info] (toastr.js:474) 
at ProductTableController.showAddToCartToast (productTable.directive.js:207) 
at ProductTableController.addToCart (productTable.directive.js:159) 
at angular.js:12332 
at f (angular.js:22949) 
at a.$$ChildScope.$$ChildScope.$eval (angular.js:14383) 
at a.$$ChildScope.$$ChildScope.$apply (angular.js:14482) 
at HTMLButtonElement.<anonymous> (angular.js:22954) 
at HTMLButtonElement.dispatch (jquery.js:4670)(anonymous function) @ angular.js:11594(anonymous function) @ angular.js:8544$apply @ angular.js:14484(anonymous function) @ angular.js:22954dispatch @ jquery.js:4670r.handle @ jquery.js:4338 

Любая идея, что случилось?

Спасибо.

+0

любая ошибка, которую вы получаете в консоли? –

+0

Нет, только тот, который я добавил в вопрос. – Ahsan

+0

demo http://codeseven.github.io/toastr/demo.html – Pravin

ответ

2

Я думаю, что вы включили Jquery файл после angular.js , Переместите файл Jquery над файлом Angularjs.

например.

1. <script src ="jquery.min.js"></script> 
2. <script src ="angular.min.js"></script> 
+0

Закрыть, toastr.js был выше angular.js – Ahsan

+0

oh .. Я знал, что проблема должна быть чем-то вроде этого. – Ved

0

вы можете использовать angular-toastr библиотеку вместо

установки: bower install angular-toastr

включают зависимость: angular.module('app', ['ngAnimate', 'toastr'])

использование в контроллере:

app.controller('foo', function($scope, toastr) { 
    toastr.success('Hello world!', 'Toastr fun!'); 
});