Skip to content
This repository has been archived by the owner on Sep 16, 2022. It is now read-only.

No provider found for @Optional() parameter #1665

Closed
Cododoc opened this issue Nov 20, 2018 · 1 comment
Closed

No provider found for @Optional() parameter #1665

Cododoc opened this issue Nov 20, 2018 · 1 comment

Comments

@Cododoc
Copy link

Cododoc commented Nov 20, 2018

Hello!
I have a problem when using @optional() class in pipe.
I declare constructor with one optional parameter. I do not declare provider in component.
When i run component I get error - "No provider found for TableService".

@Pipe('soyTable', pure: false)
class SoyTablePipe extends PipeTransform {
  /// Конструктор
  SoyTablePipe(@Optional() TableService ts) {
    if (ts != null) {
      _tableService = ts;
    }
  }

  TableService _tableService;

  /// Трансформация
  List transform(List rows, [TableService ts]) {
    if (ts != null) {
      _tableService = ts;
    }

    if (rows == null || _tableService == null) {
      return rows;
    }

    _tableService.allRows = rows;

    if (_tableService.isChanged) {
      _tableService
        ..isChanged = false
        ..rows = _tableService.allRows
        ..applyFilter()
        ..rowsCount = _tableService.filteredRows.length
        ..sort()
        ..pagination();
    }

    return _tableService.rows;
  }
}
  • Dart VM version: 2.1.0 (Tue Nov 13 18:22:02 2018 +0100) on "windows_x64"
  • Angular 5.0.0
  • Windows
  • Chrome
@leonsenft
Copy link
Contributor

Thanks for reporting! We have a fix for this pending.

@leonsenft leonsenft self-assigned this Nov 20, 2018
alorenzen pushed a commit that referenced this issue Nov 28, 2018
Previously the `@Optional()` annotation used to mark injected dependencies as
optional was ignored on pipes, meaning a "No provider found ..." error would be
thrown when attempting to instantiate a pipe with a missing optional dependency.

Fixes #1665.

PiperOrigin-RevId: 222314430
alorenzen pushed a commit that referenced this issue Nov 30, 2018
Previously the `@Optional()` annotation used to mark injected dependencies as
optional was ignored on pipes, meaning a "No provider found ..." error would be
thrown when attempting to instantiate a pipe with a missing optional dependency.

Fixes #1665.

PiperOrigin-RevId: 222314430
alorenzen pushed a commit that referenced this issue Nov 30, 2018
Previously the `@Optional()` annotation used to mark injected dependencies as
optional was ignored on pipes, meaning a "No provider found ..." error would be
thrown when attempting to instantiate a pipe with a missing optional dependency.

Fixes #1665.

PiperOrigin-RevId: 222314430
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants