@Alex10214

Как правильно пользоваться async pipe?

Приветствую, у меня вылетает такая ошибка:
core.js:6210 ERROR Error: InvalidPipeArgument: '[object Object]' for pipe 'AsyncPipe'
    at invalidPipeArgumentError (common.js:4212)
    at AsyncPipe._selectStrategy (common.js:4314)
    at AsyncPipe._subscribe (common.js:4304)
    at AsyncPipe.transform (common.js:4292)
    at Module.ɵɵpipeBind1 (core.js:25782)
    at DataComponent_div_10_Template (data.component.html:54)
    at executeTemplate (core.js:9600)
    at refreshView (core.js:9466)
    at refreshEmbeddedViews (core.js:10591)
    at refreshView (core.js:9490)


вот код component.ts:
getDataTypeArr(): void {
    this.arrDataType$ = this.dataService.getArrInSelectDataType().pipe(take(1)).subscribe( (res: []) => {
      console.log('Arr DATA TYPE', res);
    });
  }
  ngOnInit(): void {

    this.getDataTypeArr();

  }

вот строка которой я вывожу полученный массив:
<div class="box-for-select">
          <mat-form-field  appearance="standard">
            <mat-label>Select data type</mat-label>
            <mat-select>
              <mat-option>None</mat-option>
              <mat-option *ngFor="let item of arrDataType$ | async " [value]="item">
                {{item}}
              </mat-option>
            </mat-select>
          </mat-form-field>
        </div>

В консоли отображается массив, который пришел.
Arr DATA TYPE (3) ["CRYPTO", "FX", "USSTOCK"]
Но ничего не выводится на страничке. Подскажите пожалуйста что не так. Очень нужно.
  • Вопрос задан
  • 183 просмотра
Решения вопроса 1
@Alex10214 Автор вопроса
Не нужно делать subscribe!!!!
Ответ написан
Комментировать
Пригласить эксперта
Ваш ответ на вопрос

Войдите, чтобы написать ответ

Войти через центр авторизации
Похожие вопросы