Created
October 25, 2014 23:25
-
-
Save ivoputzer/411acbfd3f9c36108a88 to your computer and use it in GitHub Desktop.
applying `ngFile.js` but pushing files to model
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
.directive('ngFile', ['$parse', function($parse){ | |
return { | |
restrict: 'A', | |
require: 'ngModel', | |
link: function($scope, $element, attrs){ | |
$element.bind('change', function(event){ | |
$scope.$apply(function($scope){ | |
Array.prototype.push.apply($parse(attrs.ngModel)($scope), event.target.files || []) | |
}) | |
}) | |
} | |
} | |
}]) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment