angular

Why, using @HostListener, keypress event fires a number of time equal of the times the page is visited (ionic2/typescript)?

点点圈 提交于 2021-02-10 14:13:36
问题 I have a page in ionic 2 and I want to catch key pressed when the user is in the page. This is the code I used to do this (.ts) @Component({ selector: 'page-play', templateUrl: 'play.html' }) export class PlayPage { @HostListener('document:keypress', ['$event']) handleKeyboardEvents(event: KeyboardEvent) { console.log("keypressed!"); } constructor() { // doing a lot of things } } Unfortunately, the handleKeyboardEvents gets fired once the first time I enter in the page, twice if, after that,

ReferenceError: window is not defined Angular Universal

浪子不回头ぞ 提交于 2021-02-10 14:11:03
问题 I'm using Angular 10 and trying to implement SSR in my project. When I run the npm run serve:ssr I'm getting the below error ReferenceError: window is not defined When I googled, they suggested to add domino So below is my server.ts .... const scripts = fs.readFileSync('dist/asfc-web/browser/index.html').toString(); const window = domino.createWindow(scripts); global['window'] = window; global['document'] = window.document; .... still getting the same error, Please guide me how to resolve

Unit Testing fromEvent observable with withLatestFrom

こ雲淡風輕ζ 提交于 2021-02-10 13:45:32
问题 I have the following observables: public ngAfterViewInit(): void { fromEvent(this.showFeaturesButton.nativeElement, 'click').pipe( takeUntil(this.ngUnsubscribe), withLatestFrom(this.store.pipe(select(fromClientStorage.getSubscription))) ).subscribe(([_event, subscription]) => { this.featureModal.open(FeatureListComponent, { data: { features: subscription.features }, }); }); } I am trying to test using: it('should call modal when feature button is clicked', () => { const subscription:

Iterate through dataSource in mat-table Angular

|▌冷眼眸甩不掉的悲伤 提交于 2021-02-10 12:36:06
问题 I have problem with iterations through dataSource, where I have data for mat-table <div *ngFor="let element of arrayMain" id = "{{element}}" class="my_item"> <div><span class="skuska"><span class="mat-subheading-2">{{element}}</span></span></div> <mat-table #table [dataSource]="dataSource[1]" matSort> <ng-container matColumnDef="{{column.id}}" *ngFor="let column of columnNames"> <mat-header-cell *matHeaderCellDef mat-sort-header > {{column.value}} </mat-header-cell> <mat-cell *matCellDef="let

Iterate through dataSource in mat-table Angular

喜欢而已 提交于 2021-02-10 12:33:05
问题 I have problem with iterations through dataSource, where I have data for mat-table <div *ngFor="let element of arrayMain" id = "{{element}}" class="my_item"> <div><span class="skuska"><span class="mat-subheading-2">{{element}}</span></span></div> <mat-table #table [dataSource]="dataSource[1]" matSort> <ng-container matColumnDef="{{column.id}}" *ngFor="let column of columnNames"> <mat-header-cell *matHeaderCellDef mat-sort-header > {{column.value}} </mat-header-cell> <mat-cell *matCellDef="let

Iterate through dataSource in mat-table Angular

白昼怎懂夜的黑 提交于 2021-02-10 12:32:29
问题 I have problem with iterations through dataSource, where I have data for mat-table <div *ngFor="let element of arrayMain" id = "{{element}}" class="my_item"> <div><span class="skuska"><span class="mat-subheading-2">{{element}}</span></span></div> <mat-table #table [dataSource]="dataSource[1]" matSort> <ng-container matColumnDef="{{column.id}}" *ngFor="let column of columnNames"> <mat-header-cell *matHeaderCellDef mat-sort-header > {{column.value}} </mat-header-cell> <mat-cell *matCellDef="let

TypeError trying to run npm run build

怎甘沉沦 提交于 2021-02-10 12:12:40
问题 Running npm run build on my angular application errors out like below. I tried updating the typescript version but it doesn't help. Please suggest what can be done. Can someone please help? I read that this is due to circular dependencies. How do I resolve those in the node_modules? Object prototype may only be an Object or null: undefined TypeError: Object prototype may only be an Object or null: undefined at setPrototypeOf () at Object.__extends (C:\Users\twdas\Documents\SDTM-POC\bitbucket

TypeError trying to run npm run build

谁都会走 提交于 2021-02-10 12:11:52
问题 Running npm run build on my angular application errors out like below. I tried updating the typescript version but it doesn't help. Please suggest what can be done. Can someone please help? I read that this is due to circular dependencies. How do I resolve those in the node_modules? Object prototype may only be an Object or null: undefined TypeError: Object prototype may only be an Object or null: undefined at setPrototypeOf () at Object.__extends (C:\Users\twdas\Documents\SDTM-POC\bitbucket

Open a Modal Using an Option from a Dropdown - Angular 2 + ngx

泄露秘密 提交于 2021-02-10 11:58:25
问题 Using ngx-bootstrap (4) with Angular 2/CLI. Trying to use a dropdown list to select which modal to open. The modal currently works fine if I just have a button for each modal (not a dropdown), but the requirements call for a dropdown. I tried something like <select class="detailsOption" (change)="openModal($event.target.value)"> <option value="">Select Option</option> <option value={{modal1}} >Option 1</option> <option value={{modal2}}>Option 2</option> </select> <ng-template #modal1> </ng

Open a Modal Using an Option from a Dropdown - Angular 2 + ngx

早过忘川 提交于 2021-02-10 11:58:14
问题 Using ngx-bootstrap (4) with Angular 2/CLI. Trying to use a dropdown list to select which modal to open. The modal currently works fine if I just have a button for each modal (not a dropdown), but the requirements call for a dropdown. I tried something like <select class="detailsOption" (change)="openModal($event.target.value)"> <option value="">Select Option</option> <option value={{modal1}} >Option 1</option> <option value={{modal2}}>Option 2</option> </select> <ng-template #modal1> </ng