Skip to content

[Paginator] Add app-wide configuration for MatPaginatorIntl #7344

Closed
@ValeryVS

Description

@ValeryVS

Bug, feature request, or proposal:

Kind of a bug.

What is the expected behavior?

MdPaginatorIntl provided in forRoot function. That way in can both app-wide and locally configured.

What is the current behavior?

Currently, MdPaginatorModule provides copy of MdPaginatorIntl for each import of module.
https://github.com/angular/material2/blob/0e4806b06c31c4968cd23a16f73bdcee8fe44cde/src/lib/paginator/paginator-module.ts

What are the steps to reproduce?

Providing a Plunker (or similar) is the best way to get the team to see your issue.
Plunker template: https://goo.gl/DlHd6U

What is the use-case or motivation for changing an existing behavior?

I have a localization service, that sets paginator intl variables

    this.storage.subscribe((storage) => {
      this.mdPaginatorIntl.itemsPerPageLabel = storage.paginator__itemsPerPageLabel;
      this.mdPaginatorIntl.nextPageLabel = storage.paginator__nextPageLabel;
      this.mdPaginatorIntl.previousPageLabel = storage.paginator__previousPageLabel;
      this.mdPaginatorIntl.getRangeLabel = (page: number, pageSize: number, length: number): string => {
        return storage.paginator__getRangeLabel
          .replace('__START__', page.toString())
          .replace('__END__', (page + pageSize - 1).toString())
          .replace('__TOTAL__', length.toString());
      };
      this.mdPaginatorIntl.changes.next();
    });

but I can't do it once for whole application.
If I just provide own copy of MdPaginatorIntl in AppModule, it will not be used. Because feature modules of app are import MdPaginatorModule with MdPaginatorIntl provider.
I have tried to make my own paginator module, but then Type MdPaginator in ... is part of the declarations of 2 modules:

Which versions of Angular, Material, OS, TypeScript, browsers are affected?

angular 4.4.3
material 2.0.0-beta.11

Is there anything else we should know?

Metadata

Metadata

Assignees

Labels

P3An issue that is relevant to core functions, but does not impede progress. Important, but not urgentfeatureThis issue represents a new feature or feature request rather than a bug or bug fixhelp wantedThe team would appreciate a PR from the community to address this issue

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions