NgFor doesn’t update data with Pipe in Angular2

To fully understand the problem and possible solutions, we need to discuss Angular change detection — for pipes and components. Pipe Change Detection Stateless/pure Pipes By default, pipes are stateless/pure. Stateless/pure pipes simply transform input data into output data. They don’t remember anything, so they don’t have any properties – just a transform() method. Angular … Read more

Angular2: Cannot read property ‘name’ of undefined

The variable selectedHero is null in the template so you cannot bind selectedHero.name as is. You need to use the elvis operator ?. for this case: <input [ngModel]=”selectedHero?.name” (ngModelChange)=”selectedHero.name = $event” /> The separation of the [(ngModel)] into [ngModel] and (ngModelChange) is also needed because you can’t assign to an expression that uses the elvis … Read more

angular2: Error: TypeError: Cannot read property ‘…’ of undefined

That’s because abc is undefined at the moment of the template rendering. You can use safe navigation operator (?) to “protect” template until HTTP call is completed: {{abc?.xyz?.name}} You can read more about safe navigation operator here. Update: Safe navigation operator can’t be used in arrays, you will have to take advantage of NgIf directive … Read more