Happy new year to you and thanks for checking out my problem.
I was able to solve this, using the following code (a little different from my Plunkr due to copying from my source files) :
app.controller('WorkCtrl', ['$scope', '$stateParams', '$http', '$location', function($scope, $stateParams, $http, $location) {
if (!$stateParams.workId) {
$location.path('/');
}
$http.get('projects/' + $stateParams.workId + '.json').success(function(data) {
//$scope.pageClass = 'page-work'; // only use to add class for ui view
//function for next previous
var currentWorkIndex;
var l = $scope.allWorks.length;
for (var i = 0; i < l; i++) {
if ($scope.allWorks[i].id === $stateParams.workId) {
currentWorkIndex = i;
break;
}
}
var prevWorkIndex = (currentWorkIndex !== 0) ? (currentWorkIndex - 1) : (l - 1);
var nextWorkIndex = (currentWorkIndex !== l - 1) ? (currentWorkIndex + 1) : (0);
$scope.prevWork = $scope.allWorks[prevWorkIndex].id;
$scope.nextWork = $scope.allWorks[nextWorkIndex].id;
});
}]);
I really appreciate your email and look forward to maybe helping the AngularJS community in some way when i get better at coding!