zone.js

Zones in angular

谁说我不能喝 提交于 2019-12-10 02:36:21
问题 What are zones? How are angular ngZone differ from zone.js? When should they be used? Can someone help with practical examples of using ngZone? I've gone through angular documentation here however, I couldn't get complete understanding. https://angular.io/api/core/NgZone 回答1: NgZone is a wrapper around Zone.js which is a library that creates a context around asynchronous functions in order to make them trackable. Angular's change detection is heavily dependent on Zones , How? Angular needs a

Zones in angular

和自甴很熟 提交于 2019-12-05 03:36:22
What are zones? How are angular ngZone differ from zone.js? When should they be used? Can someone help with practical examples of using ngZone? I've gone through angular documentation here however, I couldn't get complete understanding. https://angular.io/api/core/NgZone NgZone is a wrapper around Zone.js which is a library that creates a context around asynchronous functions in order to make them trackable. Angular's change detection is heavily dependent on Zones , How? Angular needs a way of understanding when's the time to run the change detection, which is basically nothing but updating

Angular 4.x + Cordova : FileReader fails silently (white screen of death)

梦想的初衷 提交于 2019-12-04 14:10:35
I have an Angular 4.3 + Cordova application that used to work very well. But now, I get a blank screen on app start-up, and nothing happens any more. After digging a while I realized where it comes from : my home page is protected by a CanActivate guard that will check some file-system-persisted preferences and redirect the user to another page if this is the first run or if a required preference is missing, to fill-in the required properties. So the launch of the app depends on my CanActivate guard that depends on a PreferenceService that itself depends on a FileSystemService that I

Run ngrx/effect outside of Angular's zone to prevent timeout in Protractor

心已入冬 提交于 2019-12-03 08:29:58
问题 I just started to write e2e tests for my app and am running into timeout problems with Protractor and ngrx/effects. I have the following effect dispatching an action every couple of minutes: @Effect() setSessionTimer$ = this.actions$ .ofType(Auth.ActionTypes.SET_SECONDS_LEFT) .map(toPayload) .switchMap(secondsLeft => Observable.concat( Observable.timer((secondsLeft - 60) * 1000).map(_ => new Auth.SessionExpiringAction(60)), Observable.timer(60 * 1000).map(_ => new Auth.SessionExpiredAction())

Run ngrx/effect outside of Angular's zone to prevent timeout in Protractor

最后都变了- 提交于 2019-12-02 21:03:34
I just started to write e2e tests for my app and am running into timeout problems with Protractor and ngrx/effects. I have the following effect dispatching an action every couple of minutes: @Effect() setSessionTimer$ = this.actions$ .ofType(Auth.ActionTypes.SET_SECONDS_LEFT) .map(toPayload) .switchMap(secondsLeft => Observable.concat( Observable.timer((secondsLeft - 60) * 1000).map(_ => new Auth.SessionExpiringAction(60)), Observable.timer(60 * 1000).map(_ => new Auth.SessionExpiredAction()) )); Trying to run a Protractor test causes the test to timeout with the following error, since Angular

Angular 2 Change Detection and Zone are Different in Cordova App

心已入冬 提交于 2019-11-30 20:40:25
We are building an application using Cordova and Angular 2. I have the following code: import { Component, OnInit, ChangeDetectorRef, NgZone } from '@angular/core'; import { Location } from '@angular/common'; declare var WL : any; @Component({ selector: 'app-store', templateUrl: './store.component.html', styleUrls: ['./store.component.css'] }) export class StoreComponent implements OnInit { status: string; document: any; constructor(private _location: Location, private changeDetector: ChangeDetectorRef, private zone: NgZone) { } ngOnInit() { var collectionName = 'people'; this.status =

Angular 2 Change Detection and Zone are Different in Cordova App

二次信任 提交于 2019-11-30 04:55:28
问题 We are building an application using Cordova and Angular 2. I have the following code: import { Component, OnInit, ChangeDetectorRef, NgZone } from '@angular/core'; import { Location } from '@angular/common'; declare var WL : any; @Component({ selector: 'app-store', templateUrl: './store.component.html', styleUrls: ['./store.component.css'] }) export class StoreComponent implements OnInit { status: string; document: any; constructor(private _location: Location, private changeDetector:

Karma + Jasmine: Cannot read property 'getComponentFromError'

久未见 提交于 2019-11-29 10:55:13
I am following this tutorial: https://angular.io/guide/testing#component-test-scenarios for karma+jasmine unit testing. Here my code: import { AppComponent } from "./app.component"; import { ComponentFixture, TestBed } from "@angular/core/testing"; describe('AppComponent', () => { let component: AppComponent; let fixture: ComponentFixture<AppComponent>; let h1: HTMLElement; beforeEach(() => { TestBed.configureTestingModule({ declarations: [ AppComponent ], }); fixture = TestBed.createComponent(AppComponent); component = fixture.componentInstance; h1 = fixture.nativeElement.querySelector('h1');