Skip to main content

All Questions

Tagged with
1 vote
1 answer
726 views

DI, constructor, and field initialization execution order

I have the following example code in Angular: @Injectable({ providedIn: 'root', }) export class MyService { constructor(private dependentService: DependentService) {} // this is called second ...
philomath's user avatar
  • 2,209
0 votes
0 answers
934 views

Is it possibble to extend Router from angular?

I'm implementing a router history in a service, and it has become cumbersome to always import my custom service and the angular built-in router. I decided to import the router directly in the service ...
Murilo Maestro's user avatar
-4 votes
1 answer
97 views

Compare Array of Objects with Object in ES6 [closed]

so basically I want to compare the object of array with another object and change its value. The data is fully dynamic so I can't use static keys. here is my data this new DATA is the one I want to ...
Owais Ahmed Khan's user avatar
0 votes
1 answer
47 views

How to destructing the array of object based on property name need to map the value

I have a below specified format of the response from server , i need to map the values based on fieldnames to the formcontrol names. let userForm= ths.formbuilder.group({ firstName:[], lastName:[],...
Mohamed Sahir's user avatar
3 votes
0 answers
216 views

Why does Angular use static class instead of exported function in their source code?

I was wondering why in the Angular (2+) Framework source, they use static class for features like Validators ? See an example here : https://github.com/angular/angular/blob/9.1.0/packages/forms/src/...
ylerjen's user avatar
  • 4,279
0 votes
3 answers
161 views

How to get class function from a service that return a model

I'm having a class (userName) which its properties defined a model (casting from json). This class has also a simple function that return the full Name: export class userName { firstName: string; ...
Guy E's user avatar
  • 1,927
93 votes
16 answers
167k views

Angular: 7.2.1 ES6 class ReferenceError : Cannot access 'X' before initialization

I'm having the following TypeScript class export class Vehicule extends TrackableEntity { vehiculeId: number; constructor() { super(); return super.proxify(this); } } my typescript ...
user avatar
1 vote
1 answer
800 views

How to minimize the large number of import statement in an angular module?

In my angular module, I have 50 lines of import statements to import those classes and use in the declarations sections of the @NgModule. In C++, there is a include file concept where you can put all ...
wonderful world's user avatar
-1 votes
3 answers
387 views

Angular 6 ES6 initiate object arrays

I'm really new to javascript. I have a nested class structure where I need to initiate using a json object. My question is how can I initiate array of EventDate objects and assign to this.dates in ...
Achira Shamal's user avatar
9 votes
1 answer
2k views

Is it safe to set the tsconfig target to es6 if you don't care about old browsers?

In an Angular application, is it safe to set the tsconfig.json compilerOptions.target to "es6" (or the equivalent "es2015") if you don't care about old browsers? About this matter, in the official ...
Francesco Borzi's user avatar
2 votes
1 answer
2k views

Share and mutate object between different TypeScript classes

I have the following TypeScript code: class ClassA { options: ClassOption; B: ClassB; constructor() { this.B = new ClassB(this.options); this.changeOptions(); } ...
Vivek's user avatar
  • 493
2 votes
3 answers
2k views

Typescript How To Return Class Function Reference From Nested Object Getter

I am writing a service class which contains a collection of utility functions. Rather than exposing all of the functions as public, the functions are concatenated into a series of public objects that ...
cybernet_surfer's user avatar
7 votes
1 answer
2k views

Extending EventTarget in TypeScript (Angular 2+) when compiling to ES5

Is there a way to actually create a class, which will extend the EventTarget DOM API class? Consider, I'm having this class: class MyClass extends EventTarget { constructor() { super()...
Slava Fomin II's user avatar
0 votes
2 answers
2k views

declaring an array type of custom object to a typescript function

I hae a model of car imported into current component. Trying to declare an array of cars as a return type to one of the functions. But the compiler would not recognize the car array type. Can you ...
Rk R Bairi's user avatar
  • 1,369
0 votes
1 answer
412 views

angular2 http interceptor and inject SlimLoadingBarService does not work?

I write a http intercpetor,it is like this: import { Injectable, Inject } from '@angular/core'; import { SlimLoadingBarService } from 'ng2-slim-loading-bar'; // ... other imports in here @...
Wang Xiao's user avatar
  • 315

15 30 50 per page