add onLocationChangeSuccess event handler

watch this event and toggle class if needed.
This commit is contained in:
Jean-Baptiste Bellet
2021-01-27 10:25:05 +01:00
parent 0393e902c4
commit 48c667d2dd

View File

@@ -1,4 +1,4 @@
Darkswarm.directive "tabsetCtrl", (Tabsets, $location) ->
Darkswarm.directive "tabsetCtrl", (Tabsets, $location, $rootScope) ->
restrict: "C"
scope:
id: "@"
@@ -9,7 +9,13 @@ Darkswarm.directive "tabsetCtrl", (Tabsets, $location) ->
if $scope.navigate
path = $location.path()?.match(/^\/\w+$/)?[0]
$scope.selected = path[1..] if path
# Watch location change success event to operate back/forward buttons
$rootScope.$on "$locationChangeSuccess", ->
if $scope.navigate
path = $location.path()?.match(/^\/\w+$/)?[0]
Tabsets.toggle($scope.id, path[1..] if path)
this.toggle = (name) ->
Tabsets.toggle($scope.id, name)