Questions tagged [ngzone]

Any question related to ngZone and change detection cycle of Angular framework can use this tag

  1. Any question related to Change Detection cycle using NgZone can add this tag

  2. NgZone is derived from zone.js but NgZone is specifically being used by Angular framework to manage its "Change Detection" cycle.

  3. This tag should not be used if the question is related to zone.js and has nothing to do with Angular framework

72 questions
57
votes
3 answers

When to use Ngzone.run()?

I got a bug in my angular project which finally resolved by wrapping my code into this.zone.run(() => {/* my code here */}); as stated by this answer. My previous understanding of zone was that angular can't detect changes made by async callbacks…
dasfdsa
  • 7,102
  • 8
  • 51
  • 93
12
votes
2 answers

Angular 7 SSR - problems with NgZone

I've recently moved my company's website from React to Angular, since most our projects were already on Angular 7. Being the "use-the-latest-and-greatest" person that I am, I decided to implement server-side rendering to get the google page speed…
12
votes
1 answer

What are options to unit test requestAnimationFrame in Angular?

What are ways to unit test requestAnimationFrame? requestAnimationFrame has same nature as setTimeout/setInterval have. It is also patched by zone.js like fn's like setTimeout are patched. So options which first came to my mind are async +…
Sharikov Vladislav
  • 7,049
  • 9
  • 50
  • 87
11
votes
5 answers

Running jasmine tests for a component with NgZone dependency

How would I go ahead with running a jasmine test for the following component: @Component({ moduleId: module.id, selector: "testComp", template: "
{{value}}
", }) export class TestComp { public value: string = "This is me"; …
Andrey
  • 191
  • 1
  • 2
  • 10
9
votes
2 answers

Error No provider for NgZone

I have an application that uses Angular Google Maps to show a location. At the beginning I was able to show the map, but since a while (probably I have modified something) I am getting the following error: ERROR Error: Uncaught (in promise): Error:…
Ivett
  • 111
  • 1
  • 3
8
votes
2 answers

NullInjectorError: No provider for NgZone! (Angular 6 library)

Summary I created an Angular 6 library, but I get an error when I try to use it outside of the project in which it was created. This looks like a lot of code, but it's mostly boilerplate generated by the CLI. Minimal Working Test Case I created a…
Patrick McElhaney
  • 57,901
  • 40
  • 134
  • 167
7
votes
1 answer

Ionic 3 and Ngzone is not working - not updating the results to HTML view

I want to perform some action after Bluetooth connection is done and vice versa. Handled scenarios for connection and added success and failure handler also, and changing a flag to True and False in those handler functions. I printed that value…
Pradnya Sinalkar
  • 1,116
  • 4
  • 12
  • 26
5
votes
2 answers

Why does Angular async pipe uses cdr.markForCheck() and not cdr.detectChanges()?

I have a general Angular question: Why does Angular async pipe use cdr.markForCheck() instead of cdr.detectChanges()? What I see there are two main differences in these two 'styles': markForCheck() marks the path to be checked up to the root…
Felix
  • 3,999
  • 3
  • 42
  • 66
5
votes
2 answers

Optimal reentering the ngZone from EventEmitter event

There is a component that encapsulates some library. In order to avoid all this library's event listeners' change detection nightmare, the library is scoped outside the angular zone: @Component({ ... }) export class TestComponent { @Output() …
smnbbrv
  • 23,502
  • 9
  • 78
  • 109
5
votes
3 answers

NullInjectorError: No provider for NgZone when referencing a custom npm package

I recently followed this guide to learn how to create an angular library and publish it for my own use: https://medium.com/@nikolasleblanc/building-an-angular-4-component-library-with-the-angular-cli-and-ng-packagr-53b2ade0701e After packing the…
Billy Vlachos
  • 93
  • 2
  • 8
3
votes
1 answer

Angular 8 - Resizing image on the front-end change-detection issue

I am trying to build an image compressor service from a couple of tutorials I found online . The service itself works as expected , it receives an image as File , then it compresses it and returns an Observable . All works great , except that I want…
Mihaylov
  • 338
  • 1
  • 3
  • 13
3
votes
1 answer

When to use zone.run()?

I tried to read a lot about NgZone in angular. I got to know that angular uses zone.js for change detection. I see some code used zone.run and place few actions inside of it. What does it do actually? Still I could not figure out the actual use of…
user11907741
3
votes
1 answer

Angular async pipe not triggering change detection from NgOnChange

I came across such code. The problem was that progress bar was not disappearing after selecting item that already was in cache (when api call inside cache was made it works fine). What I was able to came up with was that change detection was not…
pstr
  • 31
  • 1
  • 4
3
votes
1 answer

Access angular NgZone instance from window.object

Is it possible to access angular(2+) ZoneJS instance (NgZone) without injecting it inside constructor like this: ... const zone = window[''] ... For now when I developing my angular library I need to do…
Dariusz Filipiak
  • 2,858
  • 5
  • 28
  • 39
2
votes
0 answers

Why my code are executed outside Angular ngZone?

I have a component Angular called login.component who permitted to login at the website with this submit function : Login.component.ts submit() { const loginSubscr = this.authService .login(this.loginForm.get('username').value,…
1
2 3 4 5