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
1answer
172 views

Angular - The complex flow of renewing expired JWT token [on hold]

This the flow: login get two tokens (access token and refresh token) and two expiration time (one for each token) from server from now on the Angular application can determine if we're logged in by ...
-2
votes
0answers
12 views

Angular 2 - View is not updated when the code is modified [closed]

I have an angular 2 project and when I run it after a code change it doesn't update the view. Below is app.component.ts: ...
1
vote
1answer
132 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 ...
1
vote
1answer
42 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 (...
1
vote
0answers
19 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 ...
1
vote
1answer
58 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 ...
2
votes
0answers
23 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
19 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 ...
3
votes
1answer
56 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? ...
5
votes
1answer
34 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 ...
0
votes
1answer
409 views

An Angular service to provide window and document objects

In some components and services I need the window and document. So I created a small service, that provides these two objects. ...
1
vote
1answer
200 views

Unit testing static method that imports environment file

I'm (very) new to writing unit tests and I'm wondering how I should approach testing a static method that constructs our API endpoints based on what the properties are set to in our ...
1
vote
1answer
37 views

Unit Test case to check if localstorage is empty once I logout of the Web app

I am trying to clear my localstorage when I am logging out of the application. I want to write a unit test case in Jasmine to check if this task is performed when logout function is run. I am writing ...
0
votes
1answer
132 views

Arhitecture of Angular 7 online shop

I created online shop with angular 7 and I am not sure is good architecture. I created 5 modules: main module products shop-cart core admin I have service : ...
1
vote
1answer
221 views

Changing http-requests conditionally

I'm new to RXJS and I have a working piece of code for http-request and subscribing to Observables from a shared service in Angular. This works, but I'd want to get rid of the nested subscriptions, ...
5
votes
1answer
99 views

Angular component for a system to store student test scores

I am designing a system and in it there is a view where teachers can see a summary of test data on students. Here is the component of it: ...
2
votes
0answers
180 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 ...
1
vote
0answers
155 views

Angular 7 - 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
17 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 ...
0
votes
2answers
787 views

Angular2/4 broadcast service using RxJS

I am no expert in RxJS as I am still learning my way around the new paradigm of Observable/Subject. I was trying to implement a broadcast service (based on NgRadio) that allows a new subscriber to ...
2
votes
0answers
55 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 ...
0
votes
1answer
57 views

Angular pipe to suppress sensitive information

I have created an Angular pipe to suppress the sensitive information like credit cards, bank account, ABA numbers etc. This is working fine but I would like to know if this is the best possible way ...
1
vote
1answer
115 views

Angular component to render currency or date values

I have an Angular component and it is just a label which renders a value and if it has an associated pipe, the output of the pipe should be rendered as value of the label. But I don't want to declare ...
1
vote
0answers
63 views

Angular 7 HttpClient POST and GET

I have googled and read many tutorials about fetching data and posting data to Rest API. But i have never seen a tutorial with how to handle the getting of new data after a POST or an PUT in a best ...
4
votes
1answer
8k views

RxJS Observable with initial value

Is it possible to get rid of the BehaviourSubject to have an Observable with an initial value? Another thing I don't like is that I'm using getValue() and then modify this value and push it with next ...
2
votes
0answers
32 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 ...
1
vote
0answers
18 views

Optimistic validation on tab change

I have a rather large UI for editing a user within a Angular application. It is split in multiple tabs and in order to reduce complexity the user cannot change the tab unless there is no validation ...
0
votes
0answers
20 views

Angular service that configures translations based on current business case

I have a simple Angular Service that pre-configures translations for the ngx-translate library based on the currently logged in business case. I'm not sure if my switch case statement within the if/...
1
vote
0answers
41 views

Angular Websocket service with wait for response sending

I am writing an Angular Websocket service that can send messages to a server and then can subscribe to the response. I am grateful for every suggestion to improve this. ...
0
votes
0answers
19 views

Angular HTTP POST with Basic Auth and Form Data

I have an API that I need to use that requires 2 things Basic auth with user: username & password: api token The request ...
1
vote
0answers
49 views

Angular component for select with custom input

I'm creating an Angular widget which combines a dropdown with a custom input. I've made it generic and am preparing a blogpost explaining my setup, and would love to get a review before I do so. The ...
0
votes
0answers
27 views

Parse json data for forms

I have this form who get all the data from json, and serialized it to make it fill in the UI of material. I was thinking about making a class and name it parses who parse all the data for the ...
8
votes
1answer
381 views

Lightweight Angular tooltip component

I made a small Popup component to show different error/success...etc. messages. Template: ...
3
votes
0answers
101 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: ...
2
votes
1answer
80 views

List component using RXJS Angular

I have a small angular project, where I have an Article component to list articles with pagination system. The default page The placeholder loader page The main objectives are: Display the ...
1
vote
0answers
56 views

@bound decorator for TypeScript

I'm working on an angular codebase that very frequently uses constructs like: <c-whatever [action]='doSomething.bind(this)'> to pass reference to the ...
1
vote
0answers
14 views

Organization project and http-Client

I did not have experience with organization project and http-client. I suppose this is the right way. I have data-storage service where I store my data from server. ...
3
votes
3answers
157 views

Angular, sort objects by their keys

I had to sort a list of objects - {name:'name', email:'email} by their keys, ex. by email, so they all be rendered with ...
0
votes
2answers
1k views

Angular 4 Application

I have created an application with Angular 4. I set up the Angular application with Angular CLI. Can anybody check this and suggest some improvements? Following is the folder structure I used: In <...
1
vote
2answers
93 views

DataService that fetches data not loaded already or loads cached values

I load an array from an API that is available throughout the user's whole session. This data is unlikely to change, so it can be cached safely. I have a DataService ...
1
vote
0answers
18 views

Angular2 “Logged In State Watcher”

I have a small website I'm working on as a hobby and I created a login page/home page so far. I wanted to get the basic login/logout functionality going before filling out the main part of my site. ...
1
vote
1answer
88 views

Language switcher, consulting browser's localStorage

I'm using angular 6 and ngx-translate. This is my switch language function ...
3
votes
0answers
2k 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, ...
8
votes
1answer
2k views

Angular directive to disable a button when clicked, allowing re-enabling as needed

I have written an Angular Directive that disables a button after it has been clicked, to prevent double posting / saving of data. This works fine in most of our use cases. However, in some situation ...
3
votes
1answer
152 views

Angular service for fetching and passing data with observables

I have an Angular service consisting of three methods: This method makes a call to my server to get a URL ...
2
votes
2answers
129 views

Filter ads according to the URL

I'm building an app in angular 4. Have a listing page which shows all ads. I want to reuse same HTML/ JS for this page for all my needs. My needs are: All ads should be shown in this page; Those ads ...
0
votes
0answers
1k views

Checkboxes behave like radio buttons with angular

This is short Angular 5 code which works as intended: check boxes behave like radio buttons - only one can be selected at a time. Both versions of 'toggleCheckbox' works but I am interested is if ...
1
vote
0answers
304 views

Angular form data over multiple components

I have a form that I have broken into several different components in Angular. By the end of the form, all the data needs to be submitted together. My thought process was to create a provider to ...
2
votes
3answers
6k views

Angular2 Route Interceptor

WARNING: Please see @MgSam's answer for a fatal bug in my original code. He has a revised version that fixes the bug. I have made a route interceptor service that has an API to hook into every event ...