Advertisement
dotphp

fileModel.js

Apr 11th, 2016
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. app.directive('fileModel', ['$parse', function($parse){
  2.         return{
  3.             restrict : 'A',
  4.             link : function(scope, element, attrs){
  5.                 var model       = $parse(attrs.fileModel);
  6.                 var modelSetter = model.assign;
  7.  
  8.                 element.bind('change', function(){
  9.                     scope.$apply(function(){
  10.                         modelSetter(scope, element[0].files[0]);
  11.                     });
  12.                 });
  13.             }
  14.         };
  15.     }]);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement