2016-11-24 71 views
-1

我正在尝试使用Toastrangular 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

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

回答

2

我想你列入angular.js后jQuery的文件。将您的jQuery的文件Angularjs文件之上。

例如。

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

关闭,toastr.js高于angular.js – Ahsan

+0

哦..我是知道的问题,必须是这样的。 – 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!'); 
}); 
相关问题