-1

I am trying to use Toastr with angular js, but getting the following error. I have included jquery.js file as expected.

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

Error message:

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. (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

Any idea what's wrong ?

Thanks.

marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459
Ahsan
  • 2,964
  • 11
  • 53
  • 96

2 Answers2

2

I think you included Jquery file after angular.js. Move your Jquery file above Angularjs file.

eg.

1. <script src ="jquery.min.js"></script>
2. <script src ="angular.min.js"></script>
Ved
  • 11,837
  • 5
  • 42
  • 60
0

you can use angular-toastr library instead

install: bower install angular-toastr

include dependency: angular.module('app', ['ngAnimate', 'toastr'])

use in controller :

app.controller('foo', function($scope, toastr) {
  toastr.success('Hello world!', 'Toastr fun!');
});
xkeshav
  • 53,360
  • 44
  • 177
  • 245