Angular 7 + ngx-bootstrap 3.1.3

Kun*_*iao 6 ngx-bootstrap angular ngx-bootstrap-modal angular7

是一个在stackblitz中的空白角度7项目,在Angular 6中使用,constructor(private bsModalRef: BsModalRef)所以我可以将值传递给我的子弹出组件.

但当我更新到角7时,它说Module not found: Error: Can't resolve 'ngx-bootstrap/modal/bs-modal-ref.service'.

在stackblitz中,它要求我安装ngx-bootstrap,但我已经安装了.

任何的想法?

Abh*_*nth 6

的第一件事是你需要改变你的进口app.component.ts

从'ngx-bootstrap / modal / bs-modal-ref.service'导入{BsModalRef};

从'ngx-bootstrap'导入{BsModalRef};

那么您将不得不在 app.module

import { NgModule } from '@angular/core';
import { BrowserModule } from '@angular/platform-browser';
import { FormsModule } from '@angular/forms';
import { BsModalRef } from 'ngx-bootstrap';

import { AppComponent } from './app.component';
import { HelloComponent } from './hello.component';
import { ModalModule } from 'ngx-bootstrap/modal';
import { BsDropdownModule } from 'ngx-bootstrap/dropdown';

@NgModule({
  imports:      [ BrowserModule, FormsModule,ModalModule.forRoot(),
  BsDropdownModule.forRoot() ],
  declarations: [ AppComponent, HelloComponent ],
  bootstrap:    [ AppComponent ],
  providers: [BsModalRef]
})
export class AppModule { }
Run Code Online (Sandbox Code Playgroud)

工作STACKBLITZ