Skip to content

Commit

Permalink
feat(pagination): added moduleless support
Browse files Browse the repository at this point in the history
  • Loading branch information
lexasq committed Jul 18, 2024
1 parent abbead9 commit c5dcf6c
Show file tree
Hide file tree
Showing 7 changed files with 20 additions and 19 deletions.
2 changes: 1 addition & 1 deletion libs/doc-pages/pagination/src/lib/docs/usage.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { PaginationModule } from 'ngx-bootstrap/pagination';

@NgModule({
imports: [PaginationModule.forRoot(),...]
imports: [PaginationModule,...]
})
export class AppModule(){}
2 changes: 1 addition & 1 deletion libs/doc-pages/pagination/src/lib/pagination.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ export { PaginationSectionComponent } from './pagination-section.component';
...DEMO_COMPONENTS
],
imports: [
PaginationModule.forRoot(),
PaginationModule,
CommonModule,
FormsModule,
DocsModule,
Expand Down
9 changes: 6 additions & 3 deletions src/pagination/pager.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import { ConfigModel, PagesModel } from './models';

import { PageChangedEvent } from './pagination.component';
import { PaginationConfig } from './pagination.config';
import { NgClass } from '@angular/common';

export const PAGER_CONTROL_VALUE_ACCESSOR: Provider = {
provide: NG_VALUE_ACCESSOR,
Expand All @@ -23,9 +24,11 @@ export const PAGER_CONTROL_VALUE_ACCESSOR: Provider = {
};

@Component({
selector: 'pager',
templateUrl: './pager.component.html',
providers: [PAGER_CONTROL_VALUE_ACCESSOR]
selector: 'pager',
templateUrl: './pager.component.html',
providers: [PAGER_CONTROL_VALUE_ACCESSOR],
standalone: true,
imports: [NgClass]
})
export class PagerComponent implements ControlValueAccessor, OnInit {
config?: Partial<ConfigModel>;
Expand Down
9 changes: 6 additions & 3 deletions src/pagination/pagination.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import { ControlValueAccessor, NG_VALUE_ACCESSOR } from '@angular/forms';
import { ConfigModel, PagesModel, PaginationLinkContext, PaginationNumberLinkContext } from './models';

import { PaginationConfig } from './pagination.config';
import { NgClass, NgIf, NgTemplateOutlet, NgFor } from '@angular/common';

export interface PageChangedEvent {
itemsPerPage: number;
Expand All @@ -27,9 +28,11 @@ export const PAGINATION_CONTROL_VALUE_ACCESSOR: Provider = {
};

@Component({
selector: 'pagination',
templateUrl: './pagination.component.html',
providers: [PAGINATION_CONTROL_VALUE_ACCESSOR]
selector: 'pagination',
templateUrl: './pagination.component.html',
providers: [PAGINATION_CONTROL_VALUE_ACCESSOR],
standalone: true,
imports: [NgClass, NgIf, NgTemplateOutlet, NgFor]
})
export class PaginationComponent implements ControlValueAccessor, OnInit {
config?: Partial<ConfigModel>;
Expand Down
13 changes: 4 additions & 9 deletions src/pagination/pagination.module.ts
Original file line number Diff line number Diff line change
@@ -1,16 +1,11 @@
import { CommonModule } from '@angular/common';
import { NgModule, ModuleWithProviders } from '@angular/core';
import { NgModule } from '@angular/core';

import { PagerComponent } from './pager.component';
import { PaginationComponent } from './pagination.component';

@NgModule({
imports: [CommonModule],
declarations: [PagerComponent, PaginationComponent],
exports: [PagerComponent, PaginationComponent]
imports: [CommonModule, PagerComponent, PaginationComponent],
exports: [PagerComponent, PaginationComponent]
})
export class PaginationModule {
static forRoot(): ModuleWithProviders<PaginationModule> {
return { ngModule: PaginationModule, providers: [] };
}
}
export class PaginationModule {}
2 changes: 1 addition & 1 deletion src/pagination/testing/pager.component.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ describe('Component: Pager:', () => {

beforeEach(() => {
TestBed.configureTestingModule({
imports: [PaginationModule.forRoot()]
imports: [PaginationModule]
});
fixture = TestBed.createComponent(PagerComponent);
context = fixture.debugElement.componentInstance;
Expand Down
2 changes: 1 addition & 1 deletion src/pagination/testing/pagination.component.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ describe('Component: Pagination:', () => {

beforeEach(() => {
TestBed.configureTestingModule({
imports: [PaginationModule.forRoot()]
imports: [PaginationModule]
});
fixture = TestBed.createComponent(PaginationComponent);
context = fixture.debugElement.componentInstance;
Expand Down

0 comments on commit c5dcf6c

Please sign in to comment.