ngIf - Expression has changed after it was checked

后端 未结 6 1508
误落风尘
误落风尘 2021-02-01 12:37

I have a simple scenario, but just can\'t get it working!

In my view I display some text in a box with limited height.

The text is being fetched from the server,

6条回答
  •  死守一世寂寞
    2021-02-01 13:04

    if you are using BehaviorSubject for sharing the value between components:

    component.ts:

    import { Observable } from 'rxjs/Observable';
    import {tap, map, delay} from 'rxjs/operators';
    
    private _user = new BehaviorSubject(null);
    user$ = this._user.asObservable();
    
    Observable.of('response').pipe(
                tap(() =>this._user.next('yourValue'),
                delay(0),
                map(() => 'result')
              );
    
    

    component.html:

    
    

提交回复
热议问题