2

I search around the web and no problem to find how display an Observable<MyModel[]>. But I don't find how display an Observable<MyModel> to a form.

I'd like display firstName value I tried this :

{{ myModel.firstName | async }} 

and I'd like use it (bidirectional) in an I tried this :

<input type="text" [(value)]="myModel.firstName">

I got this error : Cannot read property 'firstName ' of undefined at Object.eval [as updateRenderer]

Thanks,

TheBoubou
  • 19,487
  • 54
  • 148
  • 236

2 Answers2

3

Because you have to write it like this :

 {{ (myModel | async).firstName }}

With your syntax, Angular thinks that firstName is an observable, while it's a string.

0

you should use ngModel with input as

<input type="text" [ngModel]="myModel?.firstName">

or with interpolation as,

 {{ (myModel | async).firstName }}
Sajeetharan
  • 216,225
  • 63
  • 350
  • 396
  • That's strange the service does not hit the database. I log the URL and the service works fine. Strangely when I use the "interpolation" I hit the database but nothing in the input. – TheBoubou May 14 '18 at 07:08