Questions tagged typescript

Explore the latest questions and answers asked by our top developers.

Capturing product impression without making the website slow

I am working on a website where we have thousands of products. I have to capture the impression of all products users can see in their viewport. So I created a directory and I used IntersectionObserver, and referred to it inside the HTML code of that product. The issue is that it’s causing a performing […]

TS4090 Conflicting definitions for node

I currently have two repos. One that acts as the angular front end and the other a nodejs back end. The two code bases are sharing some code so I am using npm link to give access. I’m currently writing another service that will use code from the nodejs backend. After exporting the function that […]

By user187558
Categorized as angular, node.js, npm, typescript Tagged , , ,

How to bind mat autocomplete with ng form?

I work on angular 11 I face issue I can’t bind auto complete angular material with ng form for insert data insertRecord(form: NgForm) { } on html component <form #form="ngForm" (submit)="onSubmit(form)" autocomplete="off"> <mat-form-field > <input type="text" placeholder="Select Item" aria-label="Number" matInput [matAutocomplete]="auto" [formControl]="myControl" class="form-control"> <mat-autocomplete #auto="matAutocomplete" > <mat-option (click)="getselected(exp.itemName,i," *ngFor="let exp of this.filteredOptions | async;let i […]

Uncaught TypeError: Cannot read properties of undefined (reading ‘toLowerCase’) thrown

I have this error "Uncaught TypeError: Cannot read properties of undefined (reading ‘toLowerCase’) thrown". My code in jasmine: describe(‘Send()’, () => { it(‘should return a promise’, async (done) => { let data = { action: ‘get’, component: ‘/filter’, } service.send(data.component, data.action, null).then((res) => { console.log(res); done(); }); }); }); My function in typescript: send = […]

By David Angarita
Categorized as angular, karma-jasmine, typescript Tagged , ,

How to test a function that returns a promise and a obsevable?

I have this function in typescript: send = (component: string, action: string, payload: object = null) => { var data = { ‘action’: action, ‘component’: component }; if (payload !== null) { data = Object.assign(data, payload); } return new Promise((resolve, error) => {<any>(this.APIURL, data).subscribe(res => { if (res.success) { resolve(; } else { console.error(res); […]

By David Angarita
Categorized as angular, karma-jasmine, typescript Tagged , ,

How to loop through a huge json with same key names

I have a huge json file with following structure: name: ‘xxx’, worth: [123, 456, 789] children: [ {name: ‘xxx’, worth: [987, 654, 321], children: [ {name: ‘xxx’, worth: [213, 546, 879], children: []} }, {name: ‘xxx’, worth: [987, 654, 321], children: [ name: ‘xxx’, worth: [213, 546, 879], children: [] }], ] The number of […]

By Klaxx
Categorized as angular, arrays, json, typescript Tagged , , ,

I need to make a copy for clipboard taking a dynamic variable angular

HTML OBS: The Technical.url specification variable is dynamic, whenever I click the button I want to copy the url. <div fxLayout="column" fxLayoutAlign="center start" fxFlex="70" class=""> <span>{{technicalSpecification.url}}</span> </div> <div fxLayout="column" fxLayoutAlign="center end" fxFlex="10"> <button mat-icon-button> <mat-icon matTooltip="Copy Service URL""> content_copy </mat-icon> </button> </div> Source: Angular Questions

By Jo o
Categorized as angular, typescript Tagged ,

One of the reducer is not being triggered from effect

I have tried as below to trigger the reducer from an effect. The issue is that the effect is not trigger the reducer ‘OpenINFOWIdgetSuccess’ while returning the action. @Effect() loadInfo$ = this.actions.ofType(fromHeaderActions.EInfoActions.OPEN_INFO).pipe( withLatestFrom(, switchMap(([action, infoPayLoad]) => { let cAction: fromHeaderActions.OpenINFOWIdget = <fromHeaderActions.OpenINFOWIdget>action; return this.infoService.loadINFO(infoPayLoad).pipe( // Dispatch success action map(response => new fromHeaderActions.OpenINFOWIdgetSuccess(response)), catchError(error => […]

Property binding not working for [routerlink] ANGULAR

I want to create generic url for my menu from db If I hard code the router link for example with the value memo then the application works <ul> <li *ngFor="let menu of contractMenus"><a [routerLink]="[‘memo’]">{{ menu.facetName }}</a></li> </ul> However if I want to make it generic like so <ul> <li *ngFor="let menu of contractMenus"><a [routerLink]="[‘{{ […]

By Junior Cortenbach
Categorized as angular, html, typescript Tagged , ,

Angular – Access list of child components on page load

I am using Angular 10 for a side-project of mine. I have a page that, on page load, retrieves a list of entries (in this case specifically spells) from the server and renders 1 child-component (<app-spell> component) per entry on that page. The user can (this is optional) specify a url parameter called name and […]

By Philipp Doerner
Categorized as angular, typescript, viewchildren Tagged , ,
1 1,016

Still Have Questions?

Our dedicated development team is here for you!

We can help you find answers to your question for as low as 5$.

Contact Us