async pipe works different with .? operator after upgrade to RC.5
See original GitHub issueI’m submitting a … (check one with “x”)
[x ] bug report
[ ] feature request
[ ] support request => Please do not submit support request here, instead see https://github.com/angular/angular/blob/master/CONTRIBUTING.md#question
In templates where value is Observable
{{(value|async)?.number}}
Current behavior Cannot read property ‘number’ of null
But when I wrote Pipe with simple value && value.number and changed template
{{value|async|customPipe}}
All works as expected. Sad but I can’t reproduce it in generic project
Expected/desired behavior No error, but when data come then value updated
Please tell us about your environment:
- Angular version: 2.0.0-rc.5
- Browser: Chrome 53
- Language: TypeScript 2.0
Issue Analytics
- State:
- Created 7 years ago
- Comments:9 (6 by maintainers)
Top Results From Across the Web
angular - Use async pipe with "||" operator doesnt work correctly
Assuming that someSubscription$ isn't an Observable<boolean> , you can then perform a strict test to differentiate output . <div *ngIf="( ...
Read more >AsyncPipe - Angular
The async pipe subscribes to an Observable or Promise and returns the latest value it has emitted. When a new value is emitted,...
Read more >5 Common Mistakes with RxJS - Bits and Pieces
One of the most commonly used operators is mergeMap . This operator allows you to flatten an inner Observable and will maintain many...
Read more >How to use the ASYNC PIPE effectively in Angular Templates
You can use the async pipe in Angular to automatically subscribe to and unsubscribe from observables, and display data in the template.
Read more >Fix list for IBM WebSphere Application Server V8.5
The following is a complete listing of fixes for V8.5 with the most recent fix at ... PH39568, StopServer and serverStatus fails to...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
@ericcarraway oh yeah I see… Thanks so much!
The issue is the assumption that generating an expression twice will generate the same expression producing the same value. The generated code looks like:
This observes two values coming from the pipe instead of just the first one. It checks the first for
null
then assumes the second will be non-null. The solution is to introduce a temporary storing the result of the first invocation. The would result in code like,I will work on introducing the temporary variable.