[英]Toastr not working in conjuction with AngularJs
我正在尝试将Toastr
与angular js
,但遇到以下错误。 我已经按预期包括了jquery.js
文件。
src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"
错误信息:
angular.js:11594 TypeError:无法读取未定义的属性'extend'
在m(toastr.js:474)
在Object.o [作为信息](toastr.js:474)
在ProductTableController.showAddToCartToast(productTable.directive.js:207)
在ProductTableController.addToCart(productTable.directive.js:159)
在angular.js:12332
在f(angular.js:22949)
在HTMLButtonElement的a。$$ ChildScope。$$ ChildScope。$ apply(angular.js:14482)处的a。$$ ChildScope。$$ ChildScope。$ eval(angular.js:14383)处。 (angular.js:22954)at HTMLButtonElement.dispatch(jquery.js:4670)(匿名函数)@ angular.js:11594(匿名函数)@ angular.js:8544 $ apply @ angular.js:14484(匿名函数) @ angular.js:22954dispatch @ jquery.js:4670r.handle @ jquery.js:4338
知道有什么问题吗?
谢谢。
我认为您在angular.js之后包含了Jquery文件。 将您的Jquery文件移到Angularjs文件上方。
例如。
1. <script src ="jquery.min.js"></script>
2. <script src ="angular.min.js"></script>
您可以改用angular-toastr库
安装: bower install angular-toastr
包含依赖项: angular.module('app', ['ngAnimate', 'toastr'])
在控制器中使用:
app.controller('foo', function($scope, toastr) {
toastr.success('Hello world!', 'Toastr fun!');
});
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.