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

No provider found for @Optional() parameter #1665

@Cododoc

Description

@Cododoc

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

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions