Last call to make your voice heard! Our 2022 Developer Survey closes in less than a week. Take survey.

Questions tagged [angular-2+]

Use this tag on posts involving code written with versions 2 & above of Angular, the web framework from Google. Use the 'angular.js' tag for posts involving the older AngularJS (1.x) framework.

Filter by
Sorted by
Tagged with
0 votes
0 answers
28 views

Writing in multiple selected text inputs simultaneously

I'm mostly looking for improvements in readability / performance / use of Angular and RxJS. Code: ...
user avatar
  • 219
0 votes
0 answers
11 views

Dynamic forms with angular

I've written open source plugin for dynamic forms, you can check out the code here: https://www.npmjs.com/package/ng-formality My main concern is that as ...
user avatar
  • 101
0 votes
1 answer
25 views

Validating with both a field validator and a form valdator

This (minimal demo) code obviously works, but I am a bit taken aback by the hoops I needed to jump through (and little to no mention in Angular (v13) documentation about the technique). I'm still ...
user avatar
  • 153
1 vote
1 answer
103 views

Convert from get response to array of type

I would like to know if this is the best/most efficient/industry standard way of converting from the http response to an array of typed values: Type class: ...
user avatar
  • 157
0 votes
1 answer
37 views

Simple refactor of value changes typescript

Hello all I am using some typescript reactive forms, like this ...
user avatar
-1 votes
1 answer
83 views

If condition in combineLatest observables [closed]

I have many observables so I use combineLatest in RxJS. After get all results I need to check one of value by using if condition. If the condition meets then call ...
user avatar
  • 369
1 vote
1 answer
40 views

Typescript error handler

I wrote a function in Typescript which takes required parameters, optional parameters and parameters with default value. I want to use this function for error handling of http requests. I am not sure, ...
user avatar
3 votes
0 answers
251 views

Custom RxJS operator to prevent duplicate API calls in Angular

I have a usecase where I want to prevent unexpected duplicate Http calls. I'm wondering if I can have a custom operator which can be used in pipe for any API as shown in below ...
user avatar
  • 31
1 vote
1 answer
35 views

Should I use standalone service for angular custom APP_INITIALIZER

I'm working on a Angular Electron application where we display loading screen while the application is starting up. This means we have to do couple of BE requests and only remove the loader when we ...
user avatar
  • 113
0 votes
1 answer
94 views

Angular and Typescript page with for loop and array

I have a page that shows the result of a quiz and depends on the number of right answer, the user get some rewards. So, if the user get just one right answer, he will get one reward, the others will ...
user avatar
  • 173
1 vote
0 answers
70 views

The proper way of creating a wrapper component for the Angular Material mat-list-option component

For an angular project I need a customized version of the mat-list-option component. I've found a solution by creating my own component and using ...
user avatar
1 vote
0 answers
196 views

My implementation of the Signal protocol for end-to-end encryption in NodeJS and Angular [closed]

I have developed a web app which lets you transfer files from A device to B device, similar to airdrop's concept, working through the server and not peer-to-peer. I didn't go with a P2P solution ...
user avatar
1 vote
1 answer
83 views

Sort an object array with two variable based on the language

I'm trying to sort a Sector array and a Province array based on the language. sector.ts: <...
user avatar
1 vote
1 answer
66 views

Hidden html elements after search click

I want to: Hide areas of my template after search click. Return its original state with the cleaning of the input related to each button. I don't know if my code exploits all the resources of ...
user avatar
  • 51
0 votes
1 answer
42 views

Typescript angular queryparams

I have some code like this ...
user avatar
4 votes
2 answers
81 views

Are there technical issues/disavdantages on this BaseService that aims to simplify calling API endpoints

I have created an angular BaseService that aims to simplify calling API endpoints I would like to know if you see any code smells, bad patterns or architecture issues. What disadvantages could this ...
user avatar
0 votes
1 answer
61 views

Unit Test case for services method in angular

I want to write the test case for Service class. My Service Class dynamic-form.service.ts ...
user avatar
2 votes
1 answer
68 views

Rxjs search in Angular

I created an rxjs search for a hiring company, but I got rejected for the following reason: -performance issue on a bigger data set. -bugs My question is how can I make this code better for the next ...
user avatar
0 votes
1 answer
63 views

RxJs - Flat nested swithMaps and pass variables on Http interceptor

How can the following method be flattened? I tried to pipe all the operators to the first pipe (from(this.fireAuth.currentUser)) but I lost access to the previous ...
user avatar
0 votes
2 answers
50 views

Verify application configuration from JSON file with matching type using TypeScript in an Angular project

To bootstrap our application we have a configuration stored in a JSON file. This config holds different settings, like definition of endpoints (e. g. an API or SMS gateway etc.) or some default values ...
user avatar
  • 245
0 votes
0 answers
32 views

Is there a better way for this ui component?

I need to create a component for displaying a list of avatar users....If the users present in the array is more then 3 I have to display a number to indicate the remaining amount of users. Example: <...
user avatar
  • 111
0 votes
1 answer
183 views

Handling a spinner for multiple REST calls

Context In an Angular application, I have three <select> boxes that are fed from the database with a relatively small data set. These boxes are part of a ...
user avatar
2 votes
0 answers
90 views

what should be the best approach to follow DRY principle here

My first component ...
user avatar
  • 129
1 vote
1 answer
45 views

Is it possible to make a re-usable icon component that doesn't create duplicate TemplateRefs

I have attempted to create an IconComponent that shows a different SVG icon depending on the string that is passed in. Example: ...
user avatar
  • 113
0 votes
1 answer
47 views

Refactor dynamic filter functions

I create this menu filter component: with this menu, in practice, you can filter on a cards list feeling free to choose different filters at the same time; the cards list returned will be the results ...
user avatar
0 votes
1 answer
41 views

Angular observables piping

I wanted to check and see if this was as efficient as can be. The goal is to get a user's data from a group of documents that contains references to users in Firestore. ngOnInit ...
user avatar
0 votes
0 answers
144 views

Best practice for multiple conditional HTML options with similar code blocks

So I'm pretty new to HTML/Angular and frontend tech in general. I'll include my code below, but as you'll see there's a LOT of commonality between the switch cases, what I'd like to try do is have ...
user avatar
  • 1
4 votes
2 answers
2k views

Angular10 RxJS - Interceptor to add/refresh JWT Token

I have a project, for which I use Tokenauthentication with JWT Tokens. I am relatively new to Angular Development and rxjs in particular, so there are a lot of concepts I am likely not yet familiar ...
user avatar
2 votes
1 answer
144 views

How to approach separation of layers mapping response to model in Angular app?

I want to organize mapping for my Angular app so that code structure would clear for other developers and I want to have as less code as possible. I have an api service that is responsible for ...
user avatar
2 votes
1 answer
784 views

Rewrite BehaviorSuject that takes either localStorage or Observable in Angular

I have this code ...
user avatar
  • 207
4 votes
2 answers
175 views

Angular Frontend login logic

This is a follow-up to this question Node.js backend login logic. I wrote the following login Angular frontend logic for my Node.js Backend (see the previous question above). Is it any good in terms ...
user avatar
  • 195
2 votes
0 answers
59 views

The best way to handle many, different requests with custom query params

I have a list of products, I would like to filter that products e.g. by number, price, type etc. using checkboxes, selects and inputs. I get my data from REST API - using query params in GET method. ...
user avatar
  • 21
2 votes
0 answers
154 views

Storing localStorage data as part of rxjs reducer?

I use ngrx in my Angular app to state management. At a certain time I was asked to save some variable to local storage and retrieve it with first load. That made ...
user avatar
  • 121
4 votes
0 answers
39 views

Is my Angular Material MessageBox component well build?

My angular knowledge is limited, so I don't know much yet about it's garbage collection etc to make sure my component can be used without any strange side effects or memory leaks. I've created a ...
user avatar
  • 378
3 votes
0 answers
22 views

Simple Effects in Angular 2+ application using Firebase, NGRX and RXJS

Made an Angular app using Firebase, RXJS and NGRX. ...
user avatar
2 votes
0 answers
30 views

Ngrx effects in angular application

...
user avatar
3 votes
0 answers
28 views

Alternative Way of comparing multiple variable's to multiple variables

Hi guys Im very very new To Angular/Typescript Im teaching my self section by section by just messing around and figuring things out. Currently im just doing loop's and outputs so I decided to write a ...
user avatar
  • 131
3 votes
1 answer
52 views

Iterating an Array Object & Assigning the Attributes Values to those that Match the Condition

Is there any approaches to reduce the below coding snippet in Angular 2+ with few lines of code by making use of ECMA Script or by some other ways ...
user avatar
2 votes
0 answers
36 views

Switching article states using state pattern

The Article model supports a bunch of transitions. Only two are shown below: star()/unstar()....
user avatar
  • 121
4 votes
0 answers
464 views

RxJS - Prevent valueChange of one form control if another form group is dirty OR an HTTP error has occurred

I've recently started working on an Angular 7 project (I'm pretty new to Angular and RxJS), and I was requested to implement this new functionality: The Problem I have to implement a component to ...
user avatar
6 votes
1 answer
59 views

Code Refactoring for Dynamic List in Angular 8

With a specific requirement of showing/hiding the pages, the following implementation has been carried out. The pages which needs to be hidden will be provided through an array ...
user avatar
  • 163
2 votes
1 answer
26 views

Javascript: Mapping combinations of input and possible suffix arrays leads to repetitive if statements

I am writing a program to combine the basic form of a word with suffix arrays following the choices from a form group (Angular 9) to receive the declination. This is the flow: The user inputs a word....
user avatar
  • 23
2 votes
0 answers
86 views

NativeScript - Angular Service to watch iOS keyboard event listeners

I'm writing an app with NativeScript 6.4.1 and Angular version 8. There are a series of UI events in iOS that you can watch to see what the keyboard is doing: https://developer.apple.com/...
user avatar
1 vote
0 answers
28 views

Angular8 & RxJs: handling Observable in interceptor

the following tutorial uses an interceptor to show/hide a loading bar: https://www.freakyjolly.com/http-global-loader-progress-bar-using-angular-interceptors/ ...
user avatar
  • 181
1 vote
0 answers
34 views

Autofilling multiple selectors Angular

Multiple forms make use of the autocomplete of material, which gives a resulting code that is repetitive and difficult to maintain. The controller is left with pairs of repeated methods [for each ...
user avatar
  • 51
2 votes
0 answers
23 views

Actions component in Angular

I have an action bar component. It helps do the CRUD operation for different component. Its only job is emit events. The emitted events are listened by the caller component. I am using a switch case ...
user avatar
  • 121
2 votes
0 answers
47 views

Group data based on dates to populate a Material Angular table with rowspans

I have this method that attaches the year and year's rowspan for a TD and Quarter and a Quarter's rowspan for the TD. Year and Quarter are 2 columns in an Angular Material Table which are calculated ...
user avatar
  • 121
2 votes
1 answer
362 views

Subscribing and manipulating data from API in Angular

I'm trying to display the fetched data on a table. I structured the data based on the columns table in the UI and stored them in an array, then *ngFor on the table ...
user avatar
1 vote
0 answers
26 views

Angular ReactiveForm Error Association

I want to associate an error message to a Validator and not have to in the html check for a specific error. aka *ngIf="controls.name.required". I've seen generic error message helpers that build up ...
user avatar
  • 4,064
5 votes
0 answers
460 views

IndexDB (RxJs) - Angular Service

Inspired by Wrapping IndexDB with RxJs. (Edit - Added a Stackblitz example). My use case is a simple, on-disk temporary cache. No errors are propagated, null ...
user avatar