I am getting Exception: No provider for PaginationCofig! when I am trying to use Pagination.
I have imported the PaginationModule in my app.module.ts and added it under imports.
Can't figure out what is wrong.
I dont know if it is the same problem. I get "No provider for AlertConfig!" if i try to follow up this getting start guide https://github.com/valor-software/ng2-bootstrap/blob/development/docs/getting-started/ng-cli.md
this works fine for me... I had the same problem with Paginator...
@Martin-Wegner is this working with module based configuration via providers using PaginationConfig in @ngModule ?
providers: [[{provide: PaginationConfig, useValue: { boundaryLinks: true, firstText: 'First', previousText: '‹', nextText: '›', lastText: 'Last', maxSize: 1 }}]
@Martin-Wegner Do you realize that?
The forRoot() method only provides PaginationConfig therefore it should work. But your provided object does not have the structure of https://github.com/valor-software/ngx-bootstrap/blob/development/src/pagination/pagination.config.ts
@Martin-Wegner It is working, thanks.
In order to fully work (properly display all pagination components such as First, Last etc.), Martin's suggestion should be followed and define the config as referenced:
import { Injectable } from '@angular/core';
/** Provides default values for Pagination and pager components */
@Injectable()
export class PaginationConfig {
main: any = {
maxSize: void 0,
itemsPerPage: 10,
boundaryLinks: false,
directionLinks: true,
firstText: 'First',
previousText: 'Previous',
nextText: 'Next',
lastText: 'Last',
pageBtnClass: '',
rotate: true
};
pager: any = {
itemsPerPage: 15,
previousText: '芦 Previous',
nextText: 'Next 禄',
pageBtnClass: '',
align: true
};
}
However, it is strange that the latest version of ngx-bootstrap (^1.9.3) and of ng2-bootstrap (^1.6.3) do not include this default value:
export declare class PaginationConfig {
main: any;
pager: any;
}
Most helpful comment
The
forRoot()method only providesPaginationConfigtherefore it should work. But your provided object does not have the structure of https://github.com/valor-software/ngx-bootstrap/blob/development/src/pagination/pagination.config.ts