简体   繁体   English

在Angular中关闭FullScreen时不会调用转义函数

[英]Escape Function Doesn't Get Called When Close FullScreen in Angular

I have a problem when i try to press the esc function so that the fullscreen of my app will close. 当我尝试按下esc功能以便我的应用程序的全屏关闭时,我遇到了问题。 The fullscreen and close fullscreen already works. 全屏和关闭全屏已经有效。 But the problem is when i'm currently in fullscreen mode and i try to click the esc, it closes the fullscreen but the word "Open" is still being shown. 但问题是,当我目前处于全屏模式并且我尝试点击esc时,它会关闭全屏,但仍会显示“打开”字样。 Please see my codes below. 请参阅下面的代码。 Please click also my stackblizk link here https://stackblitz.com/edit/fullscreen-closefullscreen?file=src%2Fapp%2Fapp.component.ts 请点击这里我的stackblizk链接https://stackblitz.com/edit/fullscreen-closefullscreen?file=src%2Fapp%2Fapp.component.ts

@HostListener('document:keydown.escape', ['$event']) onKeydownHandler(event: KeyboardEvent) {
    this.closeFullscreen();
  }


<ul class="navbar-nav">
    <li class="nav-item mr-2  d-none d-lg-block">
        <a *ngIf="toggleClass === 'ft-maximize'" href="javascript:;" class="nav-link" (click)="openFullscreen()">
            Open
        </a>
        <a *ngIf="toggleClass === 'ft-minimize'" href="javascript:;" class="nav-link" (click)="closeFullscreen()">
            Close
        </a>
    </li>
</ul>

Not sure you can fix this issue. 不确定您是否可以解决此问题。 I have some case same with you and I fix by @HostListener like below. 我有一些与你相同的情况,我通过@HostListener修复,如下所示。

@HostListener('document:fullscreenchange', ['$event'])
@HostListener('document:webkitfullscreenchange', ['$event'])
@HostListener('document:mozfullscreenchange', ['$event'])
@HostListener('document:MSFullscreenChange', ['$event'])
fullscreenmode(){

    if(this.toggleClass == 'ft-minimize'){
      this.toggleClass = 'ft-maximize';
    }
    else{
      this.toggleClass = 'ft-minimize';
    }
    console.log(this.toggleClass)
 }

Demo: https://stackblitz.com/edit/fullscreen-closefullscreen-qbickg?file=src/app/app.component.ts 演示: https//stackblitz.com/edit/fullscreen-closefullscreen-qbickg?file = src / app / app.component.ts

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Angular 2:从promise调用函数时视图不会更新 - Angular 2 : View doesn't update when function is called from promise 当 URL 参数更改时,不会调用 Angular onInit - Angular onInit doesn't get called when URL param changes 退出全屏模式时不会调用 Esc 函数 - Esc function does not get called when exiting fullscreen mode 从回调fn调用MdDialogRef.close不会关闭对话框 - MdDialogRef.close doesn't close the dialog when called from a callback fn Angular - 调用 ngOnInit() 时,ngIf* 下的元素不会呈现 - Angular - Elements that are under ngIf* doesn't render when ngOnInit() is called 即使在返回 true 时调用刷新令牌 api,Angular CanActivate 也不会路由到新路由 - Angular CanActivate doesn't route to new route when refresh token api is called even when returning true 使用routerLink角6-7时组件未获得contentChildren - Component doesn't get contentChildren when using routerLink angular 6-7 为什么在Angular2的反跳期之后没有调用我的搜索方法 - Why doesn't my search method get called after the debounce period in Angular2 User.FindFirst(ClaimTypes.NameIdentifier) 从前端调用时不检索任何内容(Angular) - User.FindFirst(ClaimTypes.NameIdentifier) doesn't retrieve anything when called from frontend (Angular) 从angular2中的按钮元素调用router.navigate时不起作用 - router.navigate doesn't work when called from button element in angular2
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM