Javascript 显示和打开引导模式

Javascript 显示和打开引导模式,javascript,jquery,typescript,Javascript,Jquery,Typescript,我需要在Angular5 web应用程序中关闭一个模式并显示另一个模式。我在Jquery中使用引导组件 $('#myModal').modal('show'); $('#myModal1').modal('hide'); 我面临一个错误,类型“JQuery”上不存在属性“modal”您需要为新版本安装npm install-D@types/bootstrap,并且如果您正在使用webpack,您还需要确保您的webpack配置正确。您需要安装npm install-D@types/bootst

我需要在Angular5 web应用程序中关闭一个模式并显示另一个模式。我在Jquery中使用引导组件

$('#myModal').modal('show');
$('#myModal1').modal('hide');

我面临一个错误,类型“JQuery”上不存在属性“modal”

您需要为新版本安装
npm install-D@types/bootstrap
,并且如果您正在使用webpack,您还需要确保您的webpack配置正确。

您需要安装
npm install-D@types/bootstrap
对于新版本,如果您使用的是webpack,您还需要确保您的webpack配置正确。

使用这些配置会使事情变得更简单

它真的很容易使用

注入NgbModal并使用.open方法打开具有特定组件的模式

import { SecondComponent} from 'second.component';
import { FirstComponent} from 'first.component';

import { NgbModal } from '@ng-bootstrap/ng-bootstrap';

export class AppComponent {
  constructor(public modalService: NgbModal) {}

  openFirstModal(){
    this.modalService.open(First)
  }

  openSecondModal(){
    // You can also get a reference to the component
    let ref = this.modalService.open(SecondComponent)
    ref.componentInstance.variable = "foo";
  }
}
使用哪一种会使事情变得更容易

它真的很容易使用

注入NgbModal并使用.open方法打开具有特定组件的模式

import { SecondComponent} from 'second.component';
import { FirstComponent} from 'first.component';

import { NgbModal } from '@ng-bootstrap/ng-bootstrap';

export class AppComponent {
  constructor(public modalService: NgbModal) {}

  openFirstModal(){
    this.modalService.open(First)
  }

  openSecondModal(){
    // You can also get a reference to the component
    let ref = this.modalService.open(SecondComponent)
    ref.componentInstance.variable = "foo";
  }
}

对于引导3和4,最好使用ng引导或ngx引导。对于引导3和4,最好使用ng引导或ngx引导。