From 788cb8ebea12bbbba549d1d376c6acac7ef01139 Mon Sep 17 00:00:00 2001 From: Elliot Shiu Date: Fri, 4 Apr 2014 16:33:25 -0700 Subject: [PATCH] Check if eventHandlers exist before trying to register them --- lib/angular-dropzone.js | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/lib/angular-dropzone.js b/lib/angular-dropzone.js index 515b8b2..e2284cb 100644 --- a/lib/angular-dropzone.js +++ b/lib/angular-dropzone.js @@ -20,9 +20,11 @@ angular.module('ngDropzone', []) var dropzone = new Dropzone(element.get(0), scope.dropzoneConfig); - Object.keys(scope.eventHandlers).forEach(function (eventName) { - dropzone.on(eventName, scope.eventHandlers[eventName]); - }); + if (scope.eventHandlers) { + Object.keys(scope.eventHandlers).forEach(function (eventName) { + dropzone.on(eventName, scope.eventHandlers[eventName]); + }); + } scope.dropzone = dropzone; }