Angular 7 ngx-bootstrap 3.1.3

前端之家收集整理的这篇文章主要介绍了Angular 7 ngx-bootstrap 3.1.3前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
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 { }

工作STACKBLITZ

猜你在找的Angularjs相关文章