diff --git a/app/js/app.js b/app/js/app.js index e167e2b..8d04206 100644 --- a/app/js/app.js +++ b/app/js/app.js @@ -26,6 +26,22 @@ } } }]) + + .directive('fileModel', ['$parse', function ($parse) { + return { + restrict: 'A', + link: function(scope, element, attrs) { + var model = $parse(attrs.fileModel); + var modelSetter = model.assign; + + element.bind('change', function(){ + scope.$apply(function(){ + modelSetter(scope, element[0].files[0]); + }); + }); + } + }; + }]) .provider('myCSRF',[function(){ var headerName = 'X-CSRFToken';