Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
ValeryVS opened this issue Sep 26, 2017 · 2 comments · Fixed by #7895
Closed

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

ValeryVS opened this issue Sep 26, 2017 · 2 comments · Fixed by #7895
Assignees
Labels
feature This issue represents a new feature or feature request rather than a bug or bug fix help wanted The team would appreciate a PR from the community to address this issue P3 An issue that is relevant to core functions, but does not impede progress. Important, but not urgent

Comments

@ValeryVS
Copy link

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?

@josephperrott josephperrott added feature This issue represents a new feature or feature request rather than a bug or bug fix P3 An issue that is relevant to core functions, but does not impede progress. Important, but not urgent md-table labels Sep 26, 2017
@jelbourn
Copy link
Member

jelbourn commented Sep 26, 2017

We should create a provider for this that provides an existing instance if there is one (similar to icon registry, viewport ruler, etc.)

@jelbourn jelbourn added the help wanted The team would appreciate a PR from the community to address this issue label Sep 26, 2017
Jefiozie added a commit to Jefiozie/material2 that referenced this issue Oct 19, 2017
If there is already a MatPaginatorIntl provider that one
If not create a new instance.

Closes angular#7344
@andrewseguin andrewseguin changed the title App-wide configuration of MdPaginatorIntl [Table] Add app-wide configuration for MatPaginatorIntl Oct 31, 2017
@andrewseguin andrewseguin changed the title [Table] Add app-wide configuration for MatPaginatorIntl [Paginator] Add app-wide configuration for MatPaginatorIntl Oct 31, 2017
andrewseguin pushed a commit that referenced this issue Nov 2, 2017
* fix(MatPaginatorIntl): Provide a provider if exists.

If there is already a MatPaginatorIntl provider that one
If not create a new instance.

Closes #7344

* style(paginator): Changed arguments, removed spacing

* style(paginator): Changed argument name.
@angular-automatic-lock-bot
Copy link

This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.

@angular-automatic-lock-bot angular-automatic-lock-bot bot locked and limited conversation to collaborators Sep 7, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
feature This issue represents a new feature or feature request rather than a bug or bug fix help wanted The team would appreciate a PR from the community to address this issue P3 An issue that is relevant to core functions, but does not impede progress. Important, but not urgent
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants