Questions tagged ecmascript-6

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

export utility classes from npm package can’t resolve module?

I have some components in a separate library npm package and I’m trying to add some utility classes except I’m receiving the error Error: Module not found: Error: Can’t resolve ‘/path/to/util/utilities’ in ‘/path/to/using-project/node_modules/my-libary/fesm2015’ It builds the library fine, and the utility classes being used work as expected until I swap the libraries /dist with the […]

By CuriousG
Categorized as angular, ecmascript-6, typescript Tagged , ,

How can I not show false or comma values in map (Typescript)?

I have here a table that retrieves roles under users using typescript. It will show users under the specific role. Right now, I’m retrieving values but have false or comma. Where specifically is wrong on my code? Please point me to the direction. Here’s my component: import { Component, OnInit } from ‘@angular/core’; import { […]

Update First element of array of object with second element of same array by comparing first and second element of same array [closed]

I have a array i need to compare elements of the array based on id and parentid if parentid matched the above element id and then update child value to second element of that array. My Array : [ {ID:1, Name:’xyz’,ParentID:null, HaveKids:true, Child:null} {ID:2, Name:’abc’,ParentID:1, HaveKids:false, Child:null} {ID:3, Name:’mno’,ParentID:1, HaveKids:false, Child:null} ] Expected Output of […]

Limit object values of Array of objects according to model/interface?

export interface CountryInterface { countryNameEnglish: string; countryName: string; } let API_DATA = [{ countryCode: "AE", countryName: "United Arab Emirates", countryNameEnglish: "United Arab Emirates", countryPhoneCode: "+971", published: true timeZone: "UTC+4" }] let countryObjectsArray: CountryInterface[] = API_DATA; In this example, we have API_DATA of which we only need two values of the object instead of having all […]

How to write javascript conditional operator statement ‘?’ without using else ‘:’ [duplicate]

So I’m using typescript in Angular and I have this code in ngOnInit() : this.authService.isAuthenticate() ? this.router.navigate([‘/waiting-list’]) but I’m getting this error: [ ‘:’ expected.ts(1005) ]. I wanna use the new way to make if else statement (with ‘?’ operator). so maybe someone knows how to make it without else ‘:’ statement. Thank you. Source: […]

By red1dev
Categorized as angular, ecmascript-6, javascript, typescript Tagged , , ,

Angular – Make Service return ES6 Map

I’m struggling with the ES6 Map Datatype in my HTTP-Service. In my Service I return an Observable, containing a Map: getLayout(dims: Map<number, [number, number]>, rels: [number, number][]): Observable<Map<number, [number, number]>> { // ES6 Map can not be json-stringified let jsonDims: { [x: number]: [number, number]; } = {} dims.forEach((dim, gid) => { jsonDims[gid] = dim […]

By TehQuila
Categorized as angular, ecmascript-6, es6-map, javascript Tagged , , ,

The ngIf check only works if I put a check for undefined but not else?

The *ng-if doesn’t work on <no-data> tag. I checked and the states is getting returned empty and hence the *ngIf is not resolving the SectionRoleType.MulakhasAlKitabAlArabi i.e throws undefined but when I put subjects[SectionRoleType.MulakhasAlKitabAlArabi] != undefined subjects[SectionRoleType.MulakhasAlKitabAlArabi] && !subjects[SectionRoleType.MulakhasAlKitabAlArabi].length in *ngIf then it works but it’s shocking that the subjects[SectionRoleType.MulakhasAlKitabAlArabi] shall do the same work i.e. […]

Update the value of nested object in the array based on the key

i have two array of objects like below, am trying to compare two arrays and looking to update the object total value of arr1 if the id matches with arr2. const arr1 = [ { id: 1, value: { total: 0 }, }, { id: 2, value: { total: 0 }, }, { id: 3, […]

By John ny
Categorized as angular, ecmascript-6, javascript, reactjs Tagged , , ,

Why i am not able to read service side response in axios?

I have my react application where in i am using axios. While doing error handling in catch block , i am not able to receive response sent by service side. Below is my client catch block : .catch((error) => { console.log(‘Error’, error.response); dispatch({ type: ERROR, payload: error, }); }); In the error object , I […]

By Avinash
Categorized as angular, axios, ecmascript-6, javascript, reactjs Tagged , , , ,

Compare 2 Object arrays and return only the 1st modified array item’s index

Trying to find the better way of getting the 1st modified array item’s index upon comparing 2 Json objects. Each object in the array has a childItems array. Below are 3 sample objects. Sorry the code looks lengthier but the changes in each object is very minimal. Json object A – Simple Object array with […]

1 14

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