0

位置更改时如何显示角度ui模态?

现在我有这些控制器:

var MainModalCtrl = function ($scope, $modal, $log) {
  $scope.open = function () {
    var modalInstance = $modal.open({
      templateUrl: 'mainMenuContent.html',
      controller: MainModalInstanceCtrl
    });
  };
};

var MainModalInstanceCtrl = function ($scope, $modalInstance) {
  $scope.close = function () {
    $modalInstance.dismiss('close');
  };
  $scope.content = 'Menu';
  $scope.showContent = function( index ) {
    $scope.content = ( index );
  };
};

当我去某个位置时,如何打开模式?谢谢。

4

1 回答 1

1

如果你不来同一条路线,那么你可以看 $routeChangeSuccess

 $scope.$on('$routeChangeSuccess', function () {
    $scope.open();
 }

如果您根本不使用路由,那么 afaik 还有一个事件 $locationChangeSuccess 您可以以相同的方式收听:

 $scope.$on('$locationChangeSuccess ', function () {
    $scope.open();
 }
于 2013-10-04T12:56:12.113 回答