angular-ui / AngularJS-StyleGuide

Example of scalable architecture for my NG-Conf 2014 talk
http://www.youtube.com/watch?v=Iw-3qgG_ipU
284 stars 49 forks source link

update Paginator.js to only remove an item when it actually exists. #27

Closed hassanbazzi closed 9 years ago

hassanbazzi commented 9 years ago

if indexOf returns -1, and we're trying to remove an item that doesn't exist, then the current code will delete the last item in the array anyways.

amirite?

ProLoser commented 9 years ago

Good catch, but do this:

if (~item)
  this.items.splice(item, 1);