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
11 views

Angular 8 + Google Maps Autocomplete : Choice of country from an input selector [closed]

I have a form for the user's address. In this form, I use "matGoogleMapsAutocomplete" to automatically complete the fields "street, number, postal code, city". Until then, everything works, but I'm ...
0
votes
0answers
8 views

Angular 8 - compare an X value from an array A to an array B, to retrieve the value Y from array B

I have an "update" form for users. - I have a drop-down field with the list of countries: countries = [{code: "BE", name: "Belgium"}, {....} ...] The user ( from a Observable with name "user"): user ...
-4
votes
0answers
13 views

Explicitly provide public for methods in angular 2+ [closed]

By default, all methods are public in Angular, unless the access modifier is specified. But according to clean code in Angular, should we explicitly provide public access modifier for a method? <...
3
votes
0answers
37 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
56 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
16 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
45 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
65 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 ...
0
votes
3answers
47 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
30 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
20 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
63 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
19 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
53 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
45 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
20 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
24 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
54 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
80 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
22 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
77 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
22 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
247 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
23 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
16 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
20 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
28 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
28 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 ...
3
votes
0answers
26 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
460 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
9 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
18 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
26 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: <...
2
votes
0answers
18 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
24 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
26 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 ...
1
vote
1answer
52 views

Creating a real unit test in Karma for Angular code [closed]

This is a piece of test code made for the Angular application. The router object is a mock provided by the RouterTestingModule dependency. I wonder if such a test can be considered a unit test (...
2
votes
0answers
294 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 ...
0
votes
0answers
23 views

Complexity of a service method to fetch search results from an API

I tried the plug in CodeMetrics for Visual Studio Code along with some of my current Angular projects, and I was a little suprised about the outcome. I have a ...
1
vote
1answer
184 views

FormArray total of each formgroup via RxJS

Stackblitz - https://stackblitz.com/edit/angular-plp4rb-formarray-total-prs9ay I'm new to RxJS observables. I've created a form array where the total for a line is ...
5
votes
1answer
38 views

Merging client names into orders using RxJS

I have an API which I can't modify. I have to use data as it is. I want to join data from two separate requests where the second request is based on data from the first one. I have a working ...
3
votes
1answer
74 views

Separating items into ordered and unordered lists

I'm trying to group all the types which have ordered-list-item & unordered-list-item into new object. How can I simplify the function and reduce multiple return statements? ...
2
votes
0answers
522 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
478 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 ...
1
vote
0answers
24 views

angular service for centralizing common grid functions

I have an angular 7 app that is data focused and as a result has dozens of grids. These grids are from the Kendo UI for ANgular component library made by Telerik. These grid components expose hooks ...