carousel - 无法将 ng-bootstrap 与 angular 9 一起使用

标签 carousel ng-bootstrap angular9

这是我的 appModule,我正在使用 ng-boostsrap 轮播

import { BrowserModule } from '@angular/platform-browser';
import { NgModule } from '@angular/core';

import { AppRoutingModule } from './app-routing.module';
import { AppComponent } from './app.component';
import { HomeComponent } from './home/home.component'; 
import { NgbModule, NgbCarousel } from '@ng-bootstrap/ng-bootstrap';

@NgModule({
  declarations: [
    AppComponent,
    HomeComponent
  ],
  imports: [
    BrowserModule,
    AppRoutingModule,
   NgbModule,
    NgbCarousel   
  ],
  providers: [],
  bootstrap: [AppComponent]
})
export class AppModule { }
每当我添加任何 ng-bootstrap 组件时,它都会出现以下错误,在这里我添加了轮播。
ERROR in node_modules/@ng-bootstrap/ng-bootstrap/carousel/carousel.d.ts:24:22 - error NG6002: Appears in the NgModule.imports of AppModule, but could not be resolved to an NgModule class.

    This likely means that the library (@ng-bootstrap/ng-bootstrap) which declares NgbCarousel has not been processed correctly by ngcc, or is not compatible with Angular Ivy. Check if a newer version of the library is available, and update if so. Also consider checking with the library's authors to see if the library is expected to be compatible with Ivy.

    24 export declare class NgbCarousel implements AfterContentChecked, AfterContentInit, OnDestroy {
                            ~~~~~~~~~~~
我也尝试过添加 angular localize
提前致谢

最佳答案

您遇到的错误是因为您在导入中添加了 NgbModule连同NgbCarousel .但是你不需要 NgbCarousel因为它已经包含在 NgbModule 中导致它给你这个错误。
您需要做的是删除NgbCarousel仅来自您的进口和使用 NgbModule .
像这样:

import { BrowserModule } from '@angular/platform-browser';
import { NgModule } from '@angular/core';

import { AppRoutingModule } from './app-routing.module';
import { AppComponent } from './app.component';
import { HomeComponent } from './home/home.component'; 
import { NgbModule } from '@ng-bootstrap/ng-bootstrap';

@NgModule({
  declarations: [
    AppComponent,
    HomeComponent
  ],

  imports: [
    BrowserModule,
    AppRoutingModule,
    NgbModule,  
  ],

  providers: [],
  bootstrap: [AppComponent]
})
export class AppModule { }
祝你好运!

关于carousel - 无法将 ng-bootstrap 与 angular 9 一起使用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/62165729/

相关文章:

javascript - 我可以动态渲染 NgModal 的 HTML吗

angular - ng-bootstrap.js 中的错误 ng-bootstrap Angular 6

javascript - 来自显示 :none to display:inline-block animation, 图像轮播

javascript - Bootstrap 4 下拉菜单和轮播不工作

javascript - 在 VueJS 项目中安装 slick carousel

javascript - 使用 Bootstrap 和 ng-bootstrap 好吗?

angular - ngmodule 不是子类型 ngmoduletype

Angular 9 引入了需要加载的全局 '$localize()' 函数

bootstrap-4 - 未捕获的类型错误 : Cannot convert object to primitive value(zone-evergreen. js:171)

javascript - 带有动画内容的轮播