'use strict';

$(document).ready(function(){

});

/**
 * @ngdoc directive
 * @name anyandgoApp.directive:tabsmod
 * @description
 * # tabsmod
 */
angular.module('anyandgoApp')
  .directive('tabsmod', function () {
    return {
      restrict: 'A',
      templateUrl: '/scripts/site/views/tabsmod.html',
      controller: function($scope, $location, PeopleService, $window, $timeout) {
        $scope.opentabs = [];
        $scope.refreshOpentabs = function (){
           PeopleService.getOpenTabs().then(function(r){
                $scope.opentabs = r.data;
           });
        }

        $scope.saveOpentab = function (id){
           PeopleService.saveOpenTab(id).then(function(r){
                $scope.refreshOpentabs();
           });
        }

        $scope.removeOpentab = function (id){
           PeopleService.removeOpenTab(id).then(function(r){
                $scope.refreshOpentabs();
                // add set timeout 100
                $timeout(function(){
                    $window.history.back();
                }, 100);
           });
        }

        $scope.refreshOpentabs();

      },
      link: function postLink(scope, element, attrs) {
      }
    };
  });

'use strict';

$(document).ready(function(){

});

/**
 * @ngdoc directive
 * @name anyandgoApp.directive:tabsmod
 * @description
 * # tabsmod
 */
angular.module('anyandgoApp')
  .directive('tabsmod', function () {
    return {
      restrict: 'A',
      templateUrl: '/scripts/site/views/tabsmod.html',
      controller: function($scope, $location, PeopleService, $window) {
        $scope.opentabs = [];
        $scope.refreshOpentabs = function (){
           PeopleService.getOpenTabs().then(function(r){
                $scope.opentabs = r.data;
           });
        }

        $scope.saveOpentab = function (id){
           PeopleService.saveOpenTab(id).then(function(r){
                $scope.refreshOpentabs();
           });
        }

        $scope.removeOpentab = function (id){
           PeopleService.removeOpenTab(id).then(function(r){
                $scope.refreshOpentabs();
                $window.history.back();
           });
        }

        $scope.refreshOpentabs();

      },
      link: function postLink(scope, element, attrs) {
      }
    };
  });

--- 
+++ 
@@ -15,7 +15,7 @@
     return {
       restrict: 'A',
       templateUrl: '/scripts/site/views/tabsmod.html',
-      controller: function($scope, $location, PeopleService, $window) {
+      controller: function($scope, $location, PeopleService, $window, $timeout) {
         $scope.opentabs = [];
         $scope.refreshOpentabs = function (){
            PeopleService.getOpenTabs().then(function(r){
@@ -32,7 +32,10 @@
         $scope.removeOpentab = function (id){
            PeopleService.removeOpenTab(id).then(function(r){
                 $scope.refreshOpentabs();
-                $window.history.back();
+                // add set timeout 100
+                $timeout(function(){
+                    $window.history.back();
+                }, 100);
            });
         }
 
Rollback history after scope apply
