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.

72 questions with no upvoted or accepted answers
Filter by
Sorted by
Tagged with
5
votes
0answers
186 views

Reference enum values in Angular template without aliasing the enum type

Is there a way to improve this code? I'd like to use the enum type PaymentMethoddirectly in the angular template without renaming it to ...
4
votes
0answers
144 views

RxJs memoized singleton selectors

I am working on an angular stack that has n amount of services that hold data in stores of this type: ...
4
votes
0answers
3k views

Angular async pipe with loading spinner and manual refresh

I have an Angular 6 app with the following requirements: Get data from a web service. Load the data when the page is displayed. Reload the data when the user requests a reload by through some UI, ...
3
votes
0answers
113 views

@angular/fire Firestore cached service

I've written a service for firebase that handles all my Firestore calls. The goal is to only read the database once on app init( load() function) and then keep a copy of the database inside local ...
3
votes
0answers
65 views

Correct and safe way of performing token exchange?

I am dipping my fingers in external apis that a user would login and retrieve a code to exchange for a token. In my case, it is for the SpotifyAPI. All the web app does it return the users top ...
3
votes
0answers
76 views

A reusable card component

I tried to create a reusable component which would allow the user to create cards which can have a header, cover image, avatar section (image, title and sub title), a description, a table, a list and ...
3
votes
0answers
71 views

Flashcard Website

In my endeavor to learn Angular, I've created a flashcard site with an F#/Mongo backend. As I'm new to Angular, I'm going to post everything; any and all feedback is welcome. First, some pictures of ...
3
votes
0answers
109 views

Fetching user information along with user posts in Angular

Here is my code with 2 services, one is messageService which is used to get user messages: ...
3
votes
0answers
181 views

Build dynamic HTTP service with Angular

I have an Ionic application, this application contains set of pages and services. Since I'm working with Ionic and Angular I decided to build reusable code for different projects, for example: HTTP ...
3
votes
0answers
272 views

Vehicle price calculation Angular service

I have written a service which can generate prices from inputs. However, I feel that this can be "refactored" because it is not flexible enough. The code "works" however I feel if I could make this ...
2
votes
0answers
61 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 ...
2
votes
0answers
14 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/...
2
votes
0answers
17 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 ...
2
votes
0answers
25 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 ...
2
votes
0answers
128 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 ...
2
votes
0answers
36 views

HTML game engine within angular

I currently have a very very basic js script that runs something 30 times per second. This is later to be used in a game engine. But now I'm not quite sure how I can best do that. This little script ...
2
votes
0answers
55 views

Need feedback for a anglar 8 simple calendar appplication with the abilily to show to dos

I just built a simple calendar app using angular 8. I would like to get some suggestions for improvements in the project. any feedback will be appreciated. I would like to know what I could have done ...
2
votes
0answers
91 views

Simple Tictactoe game in Typescript

I'm mostly wondering if I can simplify the code. I've been told that it's needlessly complicated. HTML: ...
2
votes
0answers
23 views

Angular ng-for Odd/Even Scenario

I just want to create masonry vertical layout with two divider .card-lef`` and.card-right`. Anyone have an idea to place ...
2
votes
0answers
85 views

Angular forms - reactive vs. [(ngModel)]

I am developing this angular app and it has big forms with 100 + fields. I was thinking about using [(ngModel)] without reactive forms, so that it's easier to do ...
2
votes
0answers
17 views

Submiting form and transform model to match backend

I have different model in frontend and backend. When I submit form in frontend I need to transform that object to match backend model. Is there a better way than this one: ...
2
votes
0answers
66 views

RxJs observables pipes SwitchMap and async with typealong search input

I'm using RxJs for type along search, I setup an observable to emit a value after 1 second so it behaves like http with delay. I subscribe to it via the async operator in the template, the component ...
2
votes
0answers
22 views

Recuperate user's details into fake JSON server

This is the 'details.ts' which define the user's details that I want to recuperate in a JSON (user's role, logintime, duration). ...
2
votes
0answers
392 views

Angular 8: Scroll spy implementation for a timeline Contents

I have made a timeline component that can have multiple milestone/major/minor as sub components nested within timeline container component. I have also added a side navigation for that lists all ...
2
votes
0answers
739 views

Accordion component with Angular 7

I have to made an accordion-, respectively "zippy"-component using Angular 7. I'm new to Angular. Just started with it a few weeks ago. But with some Google-usage I was able to implement the ...
2
votes
0answers
664 views

Mapping nested arrays from API response

I have some selects on my html page that I want to populate with the response from my backend API. The response looks like this JSON response ...
2
votes
0answers
147 views

Angular polling and plotting component using Firebase

I could use some help refactoring my component and service. I have a lot of nested logic and wasn't sure what I could do to improve this. I'm new to Angular 7 and their piping syntax. I suspect this ...
2
votes
0answers
32 views

Two Angular animations for modal dialogs

I'm using Ionic 4 and Angular animations to animate modals. I created the following two functions that control the animations but they share a lot of repeated code. Is there a way I can clean these up ...
2
votes
0answers
38 views

Caching different http-requests

There have been multiple discussions on caching http-requests with RXJS. In this question/proposal I want to propose a custom rxjs-operator (non-pure) to provide ...
2
votes
1answer
402 views

Parse big JSON for reactive form

I implements big reactive form on angular5. This form get data from JSON. I use formBuilder and several nested formGroups. Every field have default value before rendering form. In console output form ...
2
votes
0answers
35 views

Set a time based on hh:mm length, or set time length based on time

I am using Ionic 3, Angular 5, and moment-timezone. I have a form input that displays EndTime (in the format of 01:23 AM) and another that display the length (in ...
2
votes
0answers
52 views

Class to handle complex form using Angular ReactiveForms

I'm working with the ReactiveForms in Angular5 and trying to find a good way to do this. So, in my use case, I have a FormGroup inside my example.component.ts and when I need to add some FormControl ...
2
votes
0answers
2k views

Angular 5 Forms - Extending Form Control

Currently taking a first pass at Angular Forms with some colleagues and I'm noticing an interesting design pattern implemented by a coworker where the FormControl is being extended to allow for ...
2
votes
0answers
2k views

RXJS queue up multiple http requests and send when x conditions happens

Just started to use rxjs few weeks ago, I think I'm getting most of it right, but my code seems to be not that efficient and prone to bugs I haven't run into yet! I need to be able to send http ...
1
vote
1answer
24 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 ...
1
vote
0answers
29 views

Switching article states using state pattern

The Article model supports a bunch of transitions. Only two are shown below: star()/unstar()....
1
vote
0answers
15 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/ ...
1
vote
0answers
26 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 ...
1
vote
0answers
22 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 ...
1
vote
0answers
27 views

Custom validator for reactive forms angular

I have created like this validator for reactive form, all working but I think I used so many statements, can somebody help me to make proper validation Here is my validator ...
1
vote
0answers
26 views

Adding conditional check to display information in Angular 8

I am displaying the following information in angular 8 application. I need to display only the partnerName if it exists. ...
1
vote
0answers
22 views

Angular: Setting the browser title according to active components

In an angular application I would like to set the browser title to something that is helpful. (Helpful means that the user gets a meaningful history and can identify tabs easily). Setting the title ...
1
vote
0answers
51 views

Refactor this RXJS code

I have this angular service that is working perfectly but I'm feeling that it isn't very readable. How would you refactor it? (Simple tips as "try this instead of that..." are very welcome. I'm ...
1
vote
0answers
23 views

Making code with interdependant observables reusable

Whenever I find myself repeating the same actions across different components in my projects, I immediately feel that I should extract the code to a function. The problem this time is that I can't ...
1
vote
0answers
27 views

Pass all data through FormGroup

How can I improve this code? Is it somehow possible to remove fields from HTML and pass all necessary data through FormGroup? ...
1
vote
0answers
20 views

Angular 6+ Conditionally Chained HTTP Calls

I have a number of async calls that get chained conditionally based on the previous data dependency. I.e. perform call A -> if the result is defined/not an error execute a side effect, if not perform ...
1
vote
0answers
39 views

Setting the token for API client generated instances in an Angular application

I am developing an Angular application who also consumes an external REST API. I am also trying the OpenAPI generator using a TypeScript template. The OK path is the following: call a method that ...
1
vote
0answers
33 views

Media library project using Angular

Recently I created a small project: 'media library' (which allow to search, sort and filter items) and I will be glad if some give me constructive feedback about my code. The starting point is Angular-...
1
vote
0answers
12 views

Better way to apply class based on multiple conditions

I am using Angular 8.x. I have a table with two columns that can be sorted. You can only sort one column at a time. I have conditions that display an up and down sort icon if neither column is being ...
1
vote
0answers
33 views

Subscribe once and reuse the Angular Subscription each second

I am creating a web application using Angular 8. This application is all about talking to the stock markets server and getting the Live updates every second. I have one query here. Below is my code: <...