Skip to content
This repository has been archived by the owner on Jan 19, 2024. It is now read-only.

fix ExpressionChangedAfterItHasBeenCheckedError #142

Closed
wants to merge 1 commit into from
Closed

fix ExpressionChangedAfterItHasBeenCheckedError #142

wants to merge 1 commit into from

Conversation

thejewdude
Copy link

@thejewdude thejewdude commented Mar 24, 2017

Fixes #143.
I think we should call updateFilterWidth in ngOnInit instead of ngAfterViewInit.

The original value (1) of filterInputWidth gets bound to the underlying input element before ngAfterViewInit is called. If we call updateFilterWidth, which updates filterInputWidth, in ngAfterViewInit we will change a bound input property in the middle of a change detection loop, which angular should detect in dev mode and throw ExpressionChangedAfterItHasBeenCheckedError.

I think we should call `updateFilterWidth` in `ngOnInit` instead of `ngAfterViewInit`. 

The original value (1) of `filterInputWidth` gets bound to the underlying input element before `ngAfterViewInit` is called. If we call  `updateFilterWidth`, which updates `filterInputWidth`, in `ngAfterViewInit` we will change a bound input property in the middle of a change detection loop, which angular should detect in dev mode and throw ExpressionChangedAfterItHasBeenCheckedError.
@thejewdude thejewdude deleted the patch-1 branch March 29, 2017 12:40
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant