Hi,
I have used the heroes tutorial and when using in memory this works.
But if I get the data from an external source eg grails 3 rest api then 
adding a hero behaves differently.
The hero is added to the database (I can see that via curl) but the listing 
of heroes has a place holder for the new hero but no text (no id, no name). 
A manual refresh of the browser shows a completed list with the new hero 
properly displayed.

The browser console shows

POST http://centos64:8080/heroes   201

EXCEPTION: Error in ./HeroesComponent class HeroesComponent - inline 
template:11:23 caused by: self.context.$implicit is undefined
 
ORIGINAL EXCEPTION: self.context.$implicit is undefined


This is the code for the component

 add(name: string): void {
  name = name.trim();
  if (!name) { return; }
  this.heroService.create(name)
   .then(hero => {
    this.heroes.push(hero);
    this.selectedHero = null;
   });
 }


This is the code for the template

<ul class="heroes">
    <li *ngFor="let hero of heroes" (click)="onSelect(hero)" [class.selected
]="hero === selectedHero">
   <span class="badge">{{hero.id}}</span> {{hero.name}}
   <button class="delete" (click)="delete(hero); $event.stopPropagation()">x
</button>
  </li>
</ul>

The service is working - it updates the database so I assume that is OK.

Does anyone have any ideas?

Regards,

-- 
You received this message because you are subscribed to the Google Groups 
"Angular" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to angular+unsubscr...@googlegroups.com.
To post to this group, send email to angular@googlegroups.com.
Visit this group at https://groups.google.com/group/angular.
For more options, visit https://groups.google.com/d/optout.

Reply via email to