相关疑难解决方法(0)

如何检测用户在Angular2中导航回来?

我有一个组件,我需要检测用户是否在他的浏览器中按下了按钮以导航回来.

目前我正在订阅路由器事件.

constructor(private router: Router, private activatedRoute: ActivatedRoute) {

    this.routerSubscription = router.events
        .subscribe(event => {

            // if (event.navigatesBack()) ...

        });

}
Run Code Online (Sandbox Code Playgroud)

我知道我可以使用,window.onpopstate但在使用Angular2时感觉就像是黑客.

typescript angular2-routing angular

41
推荐指数
3
解决办法
5万
查看次数

如何在Angular 2中禁用浏览器后退按钮

我正在使用Angular 2开发一个网站.有没有办法使用Angular 2禁用或触发浏览器后退按钮?

谢谢

javascript back-button angular

11
推荐指数
6
解决办法
4万
查看次数

如何在Android手机上按回按钮时关闭ui-bootstrap模式?

我有一个示例ui-bootstrap模式(来自ui-bootstrap文档)

angular.module('ui.bootstrap.demo', ['ui.bootstrap']);
angular.module('ui.bootstrap.demo').controller('ModalDemoCtrl', function ($scope, $modal, $log) {

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

  $scope.animationsEnabled = true;

  $scope.open = function (size) {

    var modalInstance = $modal.open({
      animation: $scope.animationsEnabled,
      templateUrl: 'myModalContent.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;
  };

});

// Please note that $modalInstance represents …
Run Code Online (Sandbox Code Playgroud)

javascript twitter-bootstrap angularjs bootstrap-modal

1
推荐指数
1
解决办法
4208
查看次数