koorgoo / ngCropper

AngularJS wrapper for https://github.com/fengyuanchen/cropper
107 stars 72 forks source link

Options undefined in directive #5

Closed CristianMR closed 9 years ago

CristianMR commented 9 years ago

Hey guys, I'm testing this library and I found a problem.

In the directive, there is a preprocess function, with a $q.all than returns lastUpdatedOptions when is resolved.


$q.all(toResolve).then(function(values) {
      var lastUpdatedOptions = values[values.length-1];
      defer.resolve(lastUpdatedOptions);
    });

But in my proyect when returns the options, return undefined value because values.length is undefined. To solve this problem, I changed that line to this another

var lastUpdatedOptions = values[_.size(values)-1];

because I'm using lodash and I can know the size of the array with that method. I don't know if someone have a similar problem.

Sorry for my english. Thanks

koorgoo commented 9 years ago

I refactored promises code. No such issue should appear any more.