javascript - Angular - Next Tab Button -
using base build tabs
http://jsfiddle.net/jccrosby/ergt8/light/
angular.module('tabsapp', []) .controller('tabsctrl', ['$scope', function ($scope) { $scope.tabs = [{ title: 'one', url: 'one.tpl.html' }, { title: 'two', url: 'two.tpl.html' }, { title: 'three', url: 'three.tpl.html' }]; $scope.currenttab = 'one.tpl.html'; $scope.onclicktab = function (tab) { $scope.currenttab = tab.url; } $scope.isactivetab = function(taburl) { return taburl == $scope.currenttab; } }])
and trying implement 'proceed' , 'go back' tab buttons, rather clicking directly on 1 wish visit.
was wondering if possible implement like
$scope.nextbutton = function(tab) { $scope.currenttab = $scope.tabs[tab].next.url }
where wish place next button not in
ng-repeat='tab in tabs'
so unsure how pass in current tab!
any appreciated always.
you can find example in following fiddle :
https://jsfiddle.net/wyyhpo9n/
yo ucan still improve idea
$scope.history = {}; $scope.history.tabs = []; $scope.history.tabs.push($scope.currenttab); $scope.history.index = 0; $scope.history.maxindex = 0; $scope.previous = function() { if ($scope.history.index <= 0) return; $scope.history.index--; $scope.currenttab = $scope.history.tabs[$scope.history.index]; }; $scope.next = function() { if ($scope.history.index === $scope.history.maxindex) return; $scope.history.index++; $scope.currenttab = $scope.history.tabs[$scope.history.index]; };
Comments
Post a Comment