AngularJS, RequireJS, toastr

1k views Asked by At

I'am trying to add toastr to my app and get error "ReferenceError: toastr is not defined"

Here is my requirejs config:

requirejs.config({
baseUrl: 'scripts/lib',
waitSeconds: 200,
paths: {
  'jquery': 'jquery/jquery-1.10.2',
  'toastr': 'jquery/toastr'
},
shim: {
  toastr: ['jquery']
}

And when I tryng to add toastr as module dependency I got this error.

What should I do to fix this problem?

Thank you

1

There are 1 answers

0
avcajaraville On

I think you should better use an angular port of toaster, like AngularJS-Toaster.

The main advantage is that it will work "inside angular".

The approach you were following is not angular aware, and it wont work "inside" angular ( is not an angular module ). You will have to communicate with angular each time you use it (notify changes on your models or whatever).

Using jQuery toaster does not need to be listed as a dependency for your angular application, since its not an angular module. Toaster should be ready for use without being listed as dependency.