thenikso/angular-flexslider

Unable to remove last slide in the container

Closed this issue · 6 comments

This is due to following watchCollection,

return $scope.$watchCollection(collectionString, function(collection) {
.......
if (!(collection != null ? collection.length : void 0)) { ///<- watch only new value. So when we remove last item in the data collection it's length become 0. That makes it return without removing the slide.

return;
}
........

Suggested solution :

return $scope.$watchCollection(collectionString, function(collection, oldCollection) {
......
if (!(collection != null ? collection.length : void 0) && !(oldCollection != null ? oldCollection.length : void 0)) {
return;
}
.......

Nice catch thanks! would you be able to open a pull request for this?

Thanks. Yeah. I did the change.

Hi, i'm facing the same issue right know.

I don't know if there is a way to solve this problem ?

Hi Jaime,

As I mentioned in the first comment this issue can fix by watching old Collection.


return $scope.$watchCollection(collectionString, function(collection, oldCollection) {
......
if (!(collection != null ? collection.length : void 0) && !(oldCollection != null ? oldCollection.length : void 0)) {
return;
}


change snpashot.
image

@palinda Thanks, Actually i had doubt about adding the oldCollection (This is something that angular handle by itself?), That solve my problem thanks!

thanks @palinda, #44 has been merged