Skip to content

Migrate from 0.x.x to 1.x.x

hoeni edited this page Sep 12, 2014 · 5 revisions

How to migrate from version 0.x.x to 1.x.x

1. Rename directives

  • ng-file-select -> nv-file-select
  • ng-file-drop -> nv-file-drop
  • ng-file-over -> nv-file-over

2. Rename service

$fileUploader -> FileUploader

3. The $fileUploader.create() method has been removed

FileUploader is now an angular factory meaning the syntax for creating an uploader has changed:

var uploader = $fileUploader.create(); // BEFORE
var uploader = new FileUploader(); // NOW

4. New syntax for directives

<element nv-file-drop uploader="{Object}" options="{Object}" filters="{String}"></element>
<element nv-file-select uploader="{Object}" options="{Object}" filters="{String}"></element>
<element nv-file-over uploader="{Object}" over-class="{String}"></element>

5. New syntax for filters

uploader.filters.push({
    name: 'filterName',
    fn: function(item /*{File|FileLikeObject}*/, options) {
        // ...
    }
});

6. Callbacks instead of events

// --------------------
uploader.bind('afteraddingfile', function(event, item) {}); // EARLY
uploader.onAfterAddingFile = function(item) {}; // NOW
// --------------------
uploader.bind('afteraddingall', function(event, item) {});
uploader.onAfterAddingAll = function(item) {};
// --------------------
uploader.bind('whenaddingfilefailed', function(event, item) {});
uploader.onWhenAddingFileFailed = function(item /*{File|FileLikeObject}*/, filter, options) {};
// --------------------
uploader.bind('beforeupload', function(event, item) {});
uploader.onBeforeUploadItem = function(item) {};
// --------------------
uploader.bind('progress', function(event, item, progress) {});
uploader.onProgressItem = function(item, progress) {};
// --------------------
uploader.bind('progressall', function(event, progress) {});
uploader.onProgressAll = function(progress) {};
// --------------------
uploader.bind('success', function(event, xhr, item, response) {});
uploader.onSuccessItem = function(item, response, status, headers) {};
// --------------------
uploader.bind('error', function(event, xhr, item, response) {});
uploader.onErrorItem = function(item, response, status, headers) {};
// --------------------
uploader.bind('cancel', function(event, xhr, item, response) {});
uploader.onCancelItem = function(item, response, status, headers) {};
// --------------------
uploader.bind('complete', function(event, xhr, item, response) {});
uploader.onCompleteItem = function(item, response, status, headers) {};
// --------------------
uploader.bind('completeall', function(event) {});
uploader.onCompleteAll = function() {};
// --------------------

7. Rename CSS classes

// --------------------
ng-file-over {...};
nv-file-over {...};
// --------------------