var app = angular.module('app', []); app.controller('interactionCrtl', ['$scope', function($scope){ $scope.nextState = function(widget){ widget.stateIndex++; if(widget.stateIndex > widget.states.length - 1){ widget.stateIndex = 0; } widget.state = widget.states[widget.stateIndex]; }; }]);