Here是stackblitz中的空白角度7项目,在Angular 6中我使用了构造函数(private bsModalRef:BsModalRef),因此我可以将值传递给我的子弹出组件.
但是当我更新到角度7时,它说模块未找到:错误:无法解析’ngx-bootstrap / modal / bs-modal-ref.service’.
在stackblitz中,它要求我安装ngx-bootstrap,但我已经安装了.
任何的想法?
解决方法
首先,您需要在app.component.ts中更改导入
从
从
import { BsModalRef } from ‘ngx-bootstrap/modal/bs-modal-ref.service’;
至
import { BsModalRef } from ‘ngx-bootstrap’;
那么你将不得不在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 { }