ng-bootstrap Carousel 隐藏分页指示器,"showNavigationIndicators"在类型"NgbCarouselConfig"上不存在



我正在尝试使用

<ngb-carousel   #ngbCarouselid="ngbCarousel" [showNavigationIndicators]="false" [interval]="false" [wrap]="false" *ngIf="numReceipts() > 0" class="center-block no-indicators image-view">

但它不承认[showNavigationIndicators].

我得到的错误,只是因为"显示导航指示符">

core.js:1448 ERROR Error: Uncaught (in promise): Error: Template parse errors:
Can't bind to 'showNavigationIndicators' since it isn't a known property of 'ngb-carousel'.
1. If 'ngb-carousel' is an Angular component and it has 'showNavigationIndicators' input, then verify that it is part of this module.
2. If 'ngb-carousel' is a Web Component then add 'CUSTOM_ELEMENTS_SCHEMA' to the '@NgModule.schemas' of this component to suppress this message.
3. To allow any property add 'NO_ERRORS_SCHEMA' to the '@NgModule.schemas' of this component. ("
<div class="imgCarousel">
<ngb-carousel   #ngbCarouselid="ngbCarousel" [ERROR ->][showNavigationIndicators]="false" [interval]="false" [wrap]="false" *ngIf="numReceipts() > 0" class="): ng:///AccountsModule/ReceiptPreviewComponent.html@30:51
Error: Template parse errors:
Can't bind to 'showNavigationIndicators' since it isn't a known property of 'ngb-carousel'.
1. If 'ngb-carousel' is an Angular component and it has 'showNavigationIndicators' input, then verify that it is part of this module.
2. If 'ngb-carousel' is a Web Component then add 'CUSTOM_ELEMENTS_SCHEMA' to the '@NgModule.schemas' of this component to suppress this message.
3. To allow any property add 'NO_ERRORS_SCHEMA' to the '@NgModule.schemas' of this component. ("
<div class="imgCaro

它正在工作,但你看不到它,因为你没有包括引导 css。

您可以通过设置如下index.html来尝试堆栈闪电战:

<!DOCTYPE html>
<html>
<head>
<title>ng-bootstrap demo</title>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css" />
</head>
<body>
<my-app>loading...</my-app>
</body>
</html>

我和你有完全相同的问题。错误消息是

Property *'showNavigationArrows' does not exist on type 'NgbCarouselConfig'.*

我还没有找到解决方案,但我认为它是关于我们使用的 ng-boostrap 版本。

在导入的node_model中,在carousel-config.d.ts中,源代码在我的本地:

export declare class NgbCarouselConfig {
interval: number;
wrap: boolean;
keyboard: boolean;
}

但是,当我检查 github 时,源代码如下:

import {Injectable} from '@angular/core';
/**
* Configuration service for the NgbCarousel component.
* You can inject this service, typically in your root component, and customize the values of its properties in
* order to provide default values for all the carousels used in the application.
*/
@Injectable({providedIn: 'root'})
export class NgbCarouselConfig {
interval = 5000;
wrap = true;
keyboard = true;
pauseOnHover = true;
showNavigationArrows = true;
showNavigationIndicators = true;
}

请注意,此功能仅在 2.2.0 的轮播中可用。因此,请检查您的本地版本的ng-bootstrap。

最新更新