Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Change Detection Not Working with Routing in Zone-Less Application#39296

Copy link
Copy link
@markostanimirovic

Description

@markostanimirovic
Issue body actions

馃悶 bug report

zoneless-routing-bug

Affected Package

The issue is caused by package @angular/core

Is this a regression?

No

Description

Issue happens in zone-less environment when routing is used. If you remove <router-outlet></router-outlet> from app component template and put <app-counter></app-counter>, everything works fine.

Problem makes 傻markDirty(this) that is called immediately in ngOnInit method of counter component (see bellow Workaround 1). Then, when you click on increment or decrement button, rootContext.flags is equal to 1 (DetectChanges) instead of 0 (Empty), and because of that, tick is never scheduled:

schedule-tick

馃敩 Minimal Reproduction

  1. Clone https://github.com/markostanimirovic/zoneless-routing-bug repo
  2. Run npm install
  3. Run npm start
  4. Click on increment/decrement buttons, observe that count value is not changed
  5. Navigate to Counter 2, observe that count paragraph disappeared
  6. Navigate back to Counter, observe that count paragraph disappeared too

Workaround 1

  1. Open counter.component.ts file
  2. Comment out lines 24-29
  3. Uncomment lines 32-38

Workaround 2

  1. Open app.component.ts file
  2. Swap 傻markDirty(this) with 傻detectChanges(this) on line 21

馃實 Your Environment

Angular Version: 10.1.6

Reactions are currently unavailable

Metadata

Metadata

Assignees

Labels

P3An issue that is relevant to core functions, but does not impede progress. Important, but not urgentAn issue that is relevant to core functions, but does not impede progress. Important, but not urgentarea: coreIssues related to the framework runtimeIssues related to the framework runtimearea: zonesIssues related to zone.jsIssues related to zone.jscore: change detectionstate: confirmedstate: has PR

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions

    Morty Proxy This is a proxified and sanitized view of the page, visit original site.