Next_Prev in Angular JS

$scope.nextPrev = function(array,item,property){ var np = {}; var items = array.filter(function(i){ return i[property] == item; })[0]; np.next = function(){ var nextIndex = array.indexOf(items) + 1; if(nextIndex < 0 || typeof array[nextIndex] == 'undefined') return false; return array[nextIndex]; } np.prev = function(){ var prevIndex = array.indexOf(items) - 1; if(prevIndex < 0 || typeof array[prevIndex] == 'undefined') return false; return array[prevIndex]; } return np; }

Be the first to comment

You can use [html][/html], [css][/css], [php][/php] and more to embed the code. Urls are automatically hyperlinked. Line breaks and paragraphs are automatically generated.