Skip to content

Instantly share code, notes, and snippets.

@sk8terboi87
Created May 26, 2013 09:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sk8terboi87/5652187 to your computer and use it in GitHub Desktop.
Save sk8terboi87/5652187 to your computer and use it in GitHub Desktop.
angular.module("uploaderComponent", [])
.directive "fileupload", ->
restrict: "A"
scope:
done: "&"
progress: "&"
fail: "&"
uploadurl: "="
link: (scope, elem, attrs) ->
uploadOptions =
url: scope.uploadurl
dataType: "json"
if scope.done
uploadOptions.done = (e, data) ->
scope.$apply ->
scope.done
e: e
data: data
if scope.fail
uploadOptions.fail = (e, data) ->
scope.$apply ->
scope.fail
e: e
data: data
if scope.progress
uploadOptions.progress = (e, data) ->
scope.$apply ->
scope.progress
e: e
data: data
elem.fileupload uploadOptions
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment