ngzone

Access angular NgZone instance from window.object

自古美人都是妖i 提交于 2021-02-07 09:45:02
问题 Is it possible to access angular(2+) ZoneJS instance (NgZone) without injecting it inside constructor like this: ... const zone = window['<angular zonejs path in window object>'] ... For now when I developing my angular library I need to do this: class Test { constructor( zone: NgZone ) { initmyplugin(zone); } } But I don't wanna user to care about initialization of NgZone. 回答1: You can get hold of NgZone instance by using the following code: ng.probe(getAllAngularRootElements()[0]).injector

Access angular NgZone instance from window.object

荒凉一梦 提交于 2021-02-07 09:44:05
问题 Is it possible to access angular(2+) ZoneJS instance (NgZone) without injecting it inside constructor like this: ... const zone = window['<angular zonejs path in window object>'] ... For now when I developing my angular library I need to do this: class Test { constructor( zone: NgZone ) { initmyplugin(zone); } } But I don't wanna user to care about initialization of NgZone. 回答1: You can get hold of NgZone instance by using the following code: ng.probe(getAllAngularRootElements()[0]).injector

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

笑着哭i 提交于 2020-01-02 03:36:06
问题 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 using console.log, it changes in a component file but does not reflect in HTML. I tried using ngZone , but it's not working. Success and failure handle code are as follows: BluetoothService import { Injectable } from "@angular/core"; import { BLE }

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

若如初见. 提交于 2020-01-01 05:54:14
问题 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 very basic library with the Angular 6 CLI. ng new mylib cd mylib ng generate library example ng build --prod example I can then add <lib-example></lib-example> to src/app/app.component.html , run ng serve , and see the example component works as

Running jasmine tests for a component with NgZone dependency

家住魔仙堡 提交于 2019-12-29 08:41:07
问题 How would I go ahead with running a jasmine test for the following component: @Component({ moduleId: module.id, selector: "testComp", template: "<div>{{value}}</div>", }) export class TestComp { public value: string = "This is me"; constructor(public zone: NgZone) { this.zone.run(() => console.log("zone is here")); } } The following fails with the Can't resolve all parameters for NgZone: describe("test", () => { let fixture; let component; beforeEach(async(() => { TestBed

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

谁都会走 提交于 2019-12-05 06:07:16
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 using console.log, it changes in a component file but does not reflect in HTML. I tried using ngZone , but it's not working. Success and failure handle code are as follows: BluetoothService import { Injectable } from "@angular/core"; import { BLE } from '@ionic-native/ble'; @Injectable() export class BlueToothService { constructor(private ble: BLE){ }

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

*爱你&永不变心* 提交于 2019-12-03 16:16:43
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 very basic library with the Angular 6 CLI. ng new mylib cd mylib ng generate library example ng build --prod example I can then add <lib-example></lib-example> to src/app/app.component.html , run ng serve , and see the example component works as expected. Next I edit projects/example/src/lib/example.component.ts to add an an *ng-if="true" to the <p>

Running jasmine tests for a component with NgZone dependency

雨燕双飞 提交于 2019-11-29 14:39:06
How would I go ahead with running a jasmine test for the following component: @Component({ moduleId: module.id, selector: "testComp", template: "<div>{{value}}</div>", }) export class TestComp { public value: string = "This is me"; constructor(public zone: NgZone) { this.zone.run(() => console.log("zone is here")); } } The following fails with the Can't resolve all parameters for NgZone: describe("test", () => { let fixture; let component; beforeEach(async(() => { TestBed.configureTestingModule({ declarations: [TestComp], schemas: [NO_ERRORS_SCHEMA], providers: [NgZone] }).compileComponents; }