material icon indicating copy to clipboard operation
material copied to clipboard

Toast throws error when raised

Open nikhildev opened this issue 12 years ago • 5 comments

I'm invoking a toast like this

var hideToast = $materialToast({ template: '
' + toastMessage +'
', duration: 3000 });

But when the toast is raised, it throws an error "ReferenceError: Hammer is not defined" in angular-material/angular-material.js:4052:28

Also, when trying to destroy the toast, it raises another error "Cannot read property 'destroy' of undefined" at "angular-material/angular-material.js:4071:19"

I'm using AngularJS v1.3.0-rc.3 and Angular Material v0.0.3. Am I missing something here?

nikhildev avatar Oct 01 '14 05:10 nikhildev

Looks like Hammer isn't defined. Have you run bower install? Are you importing hammer.js either via script (src="bower_components/hammerjs/hammer.js") or via some sort of build tool?

rschmukler avatar Oct 01 '14 05:10 rschmukler

Hey Ryan,

I've recently updated using bower update. That did not result in downloading hammer.js (should it be doing that?)

I've taken a look at the repo and they dont seem to be providing it.

nikhildev avatar Oct 01 '14 06:10 nikhildev

Have you tried running bower install instead of bower update? If not, give that a try.

If it still doesn't work, try this from the root of your project directory and post the result

less bower_components/angular-material/bower.json

rschmukler avatar Oct 01 '14 06:10 rschmukler

Hey Ryan,

It was just a lame mistake from my end. I didnt notice the hammerjs folder on the root of my bower_compnents. Included that in my list of deps and it worked. Thanks :)

nikhildev avatar Oct 01 '14 12:10 nikhildev

@nikhildev glad you got it working but angular-material should have had it listed as a dependency, so it's a bit peculiar

rschmukler avatar Oct 01 '14 16:10 rschmukler