Skip to content

Conversation

@jamshidimasoud721
Copy link

Problem:

When changing mode of mat-progress-bar inside ngAfterViewInit, Angular throws ExpressionChangedAfterItHasBeenCheckedError.

Solution:

Wrapped the mode change in a setTimeout and used ChangeDetectorRef.detectChanges() to notify Angular properly.

…in example by using setTimeout and detectChanges
@jamshidimasoud721 jamshidimasoud721 requested a review from a team as a code owner July 21, 2025 12:35
@jamshidimasoud721 jamshidimasoud721 requested review from andrewseguin and crisbeto and removed request for a team July 21, 2025 12:35
@google-cla
Copy link

google-cla bot commented Jul 21, 2025

Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

View this failed invocation of the CLA check for more information.

For the most up to date status, view the checks section at the bottom of the pull request.

templateUrl: './progress-bar-expression-fix-example.html',
})
export class ProgressBarExpressionFixExample implements AfterViewInit {
mode: 'determinate' | 'indeterminate' = 'determinate';
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Converting to a signal would fix the issue in a nicer way.

@crisbeto
Copy link
Member

Closing since we generally don't have examples for cases like this.

@crisbeto crisbeto closed this Jul 22, 2025
@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 Aug 22, 2025
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.

3 participants