1
resposta

error TS2322: Type 'string | null' is not assignable to type 'string | string[] | Set<string>

Boa tarde, está exigindo que um valor seja passado ao meu "loading$", como posso contar esse erro?

<hr [ngClass]="loading$ | async">
import { Component, OnInit } from '@angular/core';
import { BehaviorSubject, map, Observable } from 'rxjs';
import { LoadingType } from './loading-type';
import { LoadingService } from './loading.service';

@Component({
  selector: 'app-loading',
  templateUrl: './loading.component.html',
  styleUrls: ['./loading.component.scss']
})
export class LoadingComponent implements OnInit {


  loading$: Observable<string>;

  constructor(
    private loadingService: LoadingService
  ) { }

  ngOnInit(): void {

    this.loading$ = this.loadingService
      .getLoading()
      .pipe(map(loadingType => loadingType.valueOf()))


  }
}
1 resposta

faz isso que funciona, ele inicia a variavel como não nula

  loading$!: Observable<string>;