你如何为模态生成永久链接

时间:2016-07-03 13:34:40

标签: angularjs twitter-bootstrap permalinks

我有一个单页面应用程序,其中所有内容在主HTML之上加载不同的Bootstrap模式。

我目前正在使用Angular和angular-ui-bootstrap模式。

另一个问题是模态没有永久链接。这是模态控制器:

angular.module('inventarioNgApp')
  .controller('WorldCtrl', function($scope, $uibModal, $log) {

    $scope.items = ['item1', 'item2', 'item3'];

    $scope.animationsEnabled = true;

    $scope.open = function(size) {

      var modalInstance = $uibModal.open({
        animation: $scope.animationsEnabled,
        templateUrl: 'views/modal.html',
        controller: 'ModalInstanceCtrl',
        size: size,
        resolve: {
          items: function() {
            return $scope.items;
          }
        }
      });

      modalInstance.result.then(function(selectedItem) {
        $scope.selected = selectedItem;
      }, function() {
        $log.info('Modal dismissed at: ' + new Date());
      });
    };

    $scope.toggleAnimation = function() {
      $scope.animationsEnabled = !$scope.animationsEnabled;
    };

  });

angular.module('inventarioNgApp')
  .controller('ModalInstanceCtrl', function($scope, $uibModalInstance, items) {

    $scope.items = items;
    $scope.selected = {
      item: $scope.items[0]
    };

    $scope.ok = function() {
      $uibModalInstance.close($scope.selected.item);
    };

    $scope.cancel = function() {
      $uibModalInstance.dismiss('cancel');
    };
  });

关于如何为模态生成永久链接的任何想法?

1 个答案:

答案 0 :(得分:0)

为模态创建路径并使用$ scope.open()打开模型弹出窗口;在控制器的初始负载。