lib/public/js/angular-file.js
function(file) {
      var deferred = $q.defer();

      var reader = angular.extend(new FileReader(), {
        onload: function(e) {
          deferred.resolve(e.target.result);
          if (!$rootScope.$$phase) $rootScope.$apply();
        },
        onerror: function(e) {
          deferred.reject(e);
          if (!$rootScope.$$phase) $rootScope.$apply();
        },
        onabort: function(e) {
          deferred.reject(e);
          if (!$rootScope.$$phase) $rootScope.$apply();
        }
        // onprogress: Gee, it'd be great to get some progress support from $q...
      });
      reader.readAsDataURL(file);

      return angular.extend(deferred.promise, {
        abort: function() { reader.abort(); }
      });
    }
function(file) {
      var deferred = $q.defer();

      var reader = angular.extend(new FileReader(), {
        onload: function(e) {
          deferred.resolve(e.target.result);
          if (!$rootScope.$$phase) $rootScope.$apply();
        },
        onerror: function(e) {
          deferred.reject(e);
          if (!$rootScope.$$phase) $rootScope.$apply();
        },
        onabort: function(e) {
          deferred.reject(e);
          if (!$rootScope.$$phase) $rootScope.$apply();
        }
        // onprogress: Gee, it'd be great to get some progress support from $q...
      });
      reader.readAsDataURL(file);

      return angular.extend(deferred.promise, {
        abort: function() { reader.abort(); }
      });
    }
function ( file ) { var deferred = $q . defer ( ) ; var reader = angular . extend ( new FileReader ( ) , { onload : function ( e ) { deferred . resolve ( e . target . result ) ; if ( ! $rootScope . $$phase ) $rootScope . $apply ( ) ; } , onerror : function ( e ) { deferred . reject ( e ) ; if ( ! $rootScope . $$phase ) $rootScope . $apply ( ) ; } , onabort : function ( e ) { deferred . reject ( e ) ; if ( ! $rootScope . $$phase ) $rootScope . $apply ( ) ; } // onprogress: Gee, it'd be great to get some progress support from $q... } ) ; reader . readAsDataURL ( file ) ; return angular . extend ( deferred . promise , { abort : function ( ) { reader . abort ( ) ; } } ) ; }
Loads a file as a data URL and returns a promise representing the file's value.
Loads a file as a data URL and returns a promise representing the file s value .