Using an asynchronous tube with angular2 does not work

Whenever I use the async channel, I get console errors.

   <component *ngFor="#c of columns | async" [column]="c"></component>

I get this console error:

EXCEPTION: Invalid argument '[object Object]' for channel 'AsyncPipe' in [columns | async in projects @ 1: 51] browser_adapter.js: 76 EXCEPTION: invalid argument '[object Object]' for channel 'AsyncPipe' in [columns | async in projects @ 1: 51]

Is something missing?

+4
source share
1 answer

columns , ( - ). . Angular2 (AsyncPipe class): https://github.com/angular/angular/blob/master/modules/angular2/src/common/pipes/async_pipe.ts#L109.

HTTP-, , columns . async , subscribe, . :

this.columns = 
   this.http.get('https://angular2.apispark.net/v1/companies/', {
     headers: headers
   }).map(res => res.json());

, "columns" , :

this.http.get('https://angular2.apispark.net/v1/companies/', {
  headers: headers
})
.map(res => res.json())
.subscribe(data => this.columns = data);

, , Thierry

+4

Source: https://habr.com/ru/post/1623542/


All Articles