Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ngIf="returnsPromise() | async" goes to infinite loop #6696

Closed
mohsen1 opened this issue Jan 26, 2016 · 3 comments
Closed

ngIf="returnsPromise() | async" goes to infinite loop #6696

mohsen1 opened this issue Jan 26, 2016 · 3 comments

Comments

@mohsen1
Copy link

mohsen1 commented Jan 26, 2016

I was experimenting with AsyncPipe that this happened. If a method is returning a promise and you pipe it to AsyncPipe it will go to infinite loop and crashes the browser.

screen shot 2016-01-25 at 8 45 42 pm

Sorry for screenshot, tab was frozen and I couldn't copy the code

@robwormald
Copy link
Contributor

this is expected behavior, because each time the method is called, you're returning a new instance of the promise, which when resolved, triggers change detection, which retrieves a new promise, which triggers change detection....

You should a) generally avoid calling methods from the view and b) assign a promise to a property

@mohsen1 mohsen1 closed this as completed Jan 27, 2016
@danrasmuson
Copy link
Contributor

@robwormald The example given in the docs describes piping a promise to AsyncPipe.

Should those docs be updated?

Source Docs

angular.io

@angular-automatic-lock-bot
Copy link

This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.

@angular-automatic-lock-bot angular-automatic-lock-bot bot locked and limited conversation to collaborators Sep 8, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants