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
-1
votes
0answers
16 views

Get Next Monday and Sunday from particular Date

Given a particular Date, want to find the next occurring Monday and Sunday. Please help In Brief: If current date is 25 May 2020(Monday) need to get next monday(1 June 2020)and Sunday(7 June 2020)...
3
votes
1answer
25 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 ...
1
vote
1answer
16 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....
-1
votes
0answers
19 views

NativeScript + Angular - how to refactor code for it to work in an external service rather than in the main app component - Android back button

I'm writing an app with NativeScript 6.4.1 and Angular 8. When there is an HTTP request in my app, I show a loading indicator with the help of an Http Interceptor. In addition to a loading indicator,...
2
votes
0answers
13 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/...
1
vote
0answers
14 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
24 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 ...
2
votes
0answers
15 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 ...
1
vote
1answer
59 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 ...
1
vote
0answers
21 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 ...
2
votes
0answers
104 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 ...
3
votes
0answers
92 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 ...
1
vote
0answers
26 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 ...
2
votes
1answer
72 views

Is returning promise form angular service bad?

What is the problem when I return a promise from angular service instead of Observable? If it's a matter of any manipulation or side-effect, that I can easily do ...
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 ...
1
vote
3answers
61 views

Simplified method with multiple if-else

I need to refactor some pice od method for drag-and-drop angular material. Here is a working method in production, I need suggestion for CLEAN way to write this method. I can't change var name and ...
2
votes
0answers
35 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 ...
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. ...
3
votes
1answer
152 views

Dynamically create array with nested objects/array

I need help to dynamically create an array with nested objects holding again an array of objects each. The structure is as follows: ...
1
vote
0answers
21 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 ...
3
votes
0answers
67 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 ...
1
vote
0answers
49 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 ...
0
votes
0answers
21 views

Using function* (generator) to load external scripts in Angular application

I'm working on an Angular application that requires two external scripts to be loaded for certain components (about 12 separate ones). Script loading is only relevant if the user navigates to a ...
0
votes
0answers
29 views

Angular pagination component

I have written an Angular component for pagination. It works like this: page count < 12 all pages are shown Example: < 1 2 *3* 4 5 6 > page count >= ...
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 ...
4
votes
0answers
136 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: ...
1
vote
1answer
16 views

Return value related to file content header

I have an attachment uploading feature in my web app. File can have type- image/png or image/jpg or ...
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 ...
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 ...
6
votes
2answers
547 views

Angular control for inputting latitude and longitude with validation

I've built a custom control to handle user input in a human-readable format, but save in a machine-format. It needs to have input validation, and to convert UI-input to a base format. I'm interested ...
1
vote
1answer
39 views

Compare multiple values of an array in the same time in Javascript [closed]

As of now the below code working As expected. But in future if the newFilterArr have new record again I want to reedit this functionality. So how to overcome this? ...
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
19 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
34 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
32 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-...
2
votes
0answers
76 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 ...
5
votes
0answers
154 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 ...
2
votes
1answer
1k views

Angular Rest API generic service and implementation service

I'm wondering if there's a better way to write the ApiService and the CategoryService so that CategoryService is basically just a call to extend ApiService with the string 'category' and the base type ...
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

Sass mixins vs Angular layout components [closed]

For a long time I've been using Angular "Layout" components so their role is basically to define layout, like padding, margin, fonts and so on. For instance, page header component: ...
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: <...
3
votes
1answer
37 views

Managing Angular subscriptions

There are different methods to get data from server in Angular application: Get Observable from the service and subscribe to it at component Create Subject at the service and subscribe to the Subject ...
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
54 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 ...
1
vote
1answer
54 views

Creating a form based on flight intentory

I have an Angular 5 project with a method named createForm. It will basically create just a form. However, the form created changes depends on the flight inventory ...
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). ...
1
vote
0answers
34 views

Processing the results of API calls and process data

I'm making use of RxJS and observables within my Angular application to process the results of API calls and process data. I've written the component and it works without any issues. However after ...