【问题标题】:Unable to build solution showing "There is no directive with "exportAs" set to "bs-modal" ("<router-outlet></router-outlet>"无法构建显示“没有将“exportAs”设置为“bs-modal”(“<router-outlet></router-outlet>”的指令
【发布时间】:2020-09-02 13:50:24
【问题描述】:

我正在使用 angular 7 bootstrap 4。我需要在模型弹出时显示会话超时。

我在运行时写的一切都没有错误吗?

我的 app-component.html

<router-outlet></router-outlet>
<div bsModal #childModal="bs-modal" class="modal fade" tabindex="-1"
     role="dialog" aria-labelledby="dialog-child-name">
  <div class="modal-dialog modal-md">
    <div class="modal-content">
      <div class="modal-header">
        <h4 id="dialog-child-name" class="modal-title pull-left">You Have Been Idle!</h4>
        <button type="button" class="close pull-right" aria-label="Close" (click)="hideChildModal()">
          <span aria-hidden="true">&times;</span>
        </button>
      </div>
      <div class="modal-body">
         {{idleState}}
        <div class="row mrgbtm">
          <div class="col-md-6">
              <button type="button" (click)="logout()" class="btn btn-danger">Logout</button>
          </div>
          <div class="col-md-6">
              <button type="button" (click)="stay()" class="btn btn-success">Stay</button>
          </div>
        </div>
      </div>
    </div>
  </div>
</div>

**而我的 app-component.ts 是 **

import { Component, OnInit, OnDestroy, ViewChild } from '@angular/core';
import { Subscription } from 'rxjs';
import { Router, NavigationEnd } from '@angular/router';
import { filter } from 'rxjs/operators';
import { Idle, DEFAULT_INTERRUPTSOURCES } from '@ng-idle/core';
import { Keepalive } from '@ng-idle/keepalive';
import { BsModalService } from 'ngx-bootstrap/modal';
import { BsModalRef } from 'ngx-bootstrap/modal';
import { ModalDirective } from 'ngx-bootstrap/modal';
import { AppService } from './shared/services/AppService';


@Component({
    selector: 'app-root',
    templateUrl: './app.component.html'
})
export class AppComponent implements OnInit, OnDestroy {
    @ViewChild('childModal', { static: false }) childModal: ModalDirective;
........
.......
}

请您向我提出解决方案

【问题讨论】:

    标签: session bootstrap-4 model angular7 popupwindow


    【解决方案1】:

    在 app.module.ts 的导入数组中导入 ModalModule.forRoot()。希望它有效!

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2020-11-23
      • 1970-01-01
      • 2017-08-10
      • 2020-01-19
      • 1970-01-01
      • 1970-01-01
      • 2022-08-24
      • 2021-09-27
      相关资源
      最近更新 更多