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.
1
vote
0answers
18 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
11 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
23 views
rxjs: 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 caching:
...
0
votes
0answers
16 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 ...
0
votes
0answers
12 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 ...
3
votes
0answers
96 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:
...
0
votes
1answer
41 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 :
...
2
votes
1answer
67 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
19 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
13 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. ...
1
vote
2answers
86 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. ...
0
votes
1answer
67 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
45 views
Language switcher, consulting browser's localStorage
I'm using angular 6 and ngx-translate. This is my switch language function
...
2
votes
0answers
645 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, ...
5
votes
1answer
153 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
91 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
...
0
votes
0answers
599 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 ...
0
votes
0answers
34 views
Two-way binding and interpolation to check “password” and “confirm password”
Assuming you have an angular template form with a "password" field and a "confirm password" field (usually a register form).
Also assuming that you use two-way binding to bind the form values with ...
1
vote
0answers
147 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 ...
0
votes
1answer
76 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 ...
0
votes
0answers
33 views
Jasmine tests for tax calculations in Angular 4
I am writing Jasmine tests in an Angular application and need to verify if I am testing correctly. If not, I would like suggestions in what area I should actually test.
If you see in the code, ...
1
vote
0answers
81 views
Angular 5: Writing clean component that includes services & popups [closed]
At the beginning I am new to Angular 5, and I wrote the application below (Copy-pasted from original code with some renamings).
I want to clarify:
1- Is my code clean and follow best practices? I m ...
4
votes
1answer
666 views
Filtering objects according to required and preferred attributes
This my opportunity object which is a part of my angular app.component.ts file. In my template(HTML of this component) I want to ...
3
votes
3answers
132 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 ...
3
votes
1answer
357 views
Storing a fetched list of printers in Angular
I have a need to store data retrieved my ASP.NET Web Api to stop making redundant API calls for the same data when I navigate through my Angular page. On my API I have a database which stores a list ...
3
votes
0answers
34 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 ...
1
vote
0answers
38 views
Fetching student and teacher data from a given date range
I have two APIs which fetch data of teachers and students from a given date range. I am using forkJoin to get both APIresponse and display the data with a regular interval of 10 ms.
This is working ...
4
votes
0answers
131 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 ...
1
vote
0answers
40 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 ...
1
vote
0answers
55 views
Angular - Using Observables and subscribing to its changes [closed]
I have a component and a service. The service is contacting an API and gets a data which should be handled in the component. Now, I can do it in two ways:
Create a public ...
1
vote
0answers
452 views
Autosave reactive forms
I'm building an autosave for a data driven form on Angular.
Here is our code snippet:
...
2
votes
1answer
48 views
API calls organization in Ionic (Angular) application
I'm doing a prototype of server API calls in my Ionic (Angular) application. I'm considering this use case:
...
0
votes
0answers
35 views
Angular2 and RxJS passing objects around with a service
Let's say I want to share an object between multiple components. This service will allow components to send or receive the object.
This functionality allows for an object to be Globally Accessible. ...
2
votes
0answers
852 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
888 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 ...
0
votes
0answers
1k views
Angular 2 Autocomplete
I've tried to build a fairly simple, reusable and functional Angular2 autocomplete component.
The component:
...
1
vote
0answers
49 views
Calling Service and Initiate under ngOnOnit (not in Constructor) Hook in Angular4
I am using WP REST API V2 with Angular v5.
I am display all items available from API for /do route inside WeDoComponent ...
3
votes
1answer
250 views
Angular + Redux app organization and initialization: transfer from a PHP-driven website
Our system is largely a PHP-driven system. We're not doing the full split back/front-end. Most pages are plain HTML served directly by PHP. However, a few parts of the system are very dynamic and ...
2
votes
1answer
512 views
Angular - reusing an observable for different queries
This is just a dummy example, but in my real world application I get a lot of data from the web API and I'd like to manipulate it on the client's side. So, I kind of stored the observable I get from ...
1
vote
0answers
49 views
Pig game in Angular4
I am a newb in Angular 4. I have written a component but have some questions.
I used member variables of class and modified variables within functions.
Is this right approach or I should implement it ...
8
votes
1answer
325 views
Lightweight Angular tooltip component
I made a small Popup component to show different error/success...etc. messages.
Template:
...
1
vote
1answer
36 views
Logging observable values while extending service
I'm trying to extend a service function which returns an Observable<T>. The idea is to extend the function so I can add logging functionality whenever the ...
1
vote
0answers
62 views
single component angular 4 / node.js app
I take part in the recruitment process and I have done a small task for it - a searchable map of bus stops in angular with node backend. I am new to angular and I need someone to do a serious code ...
2
votes
1answer
37 views
Angular2 Toggling showing and hiding between two elements
I have a tabs nav element that has two tabs, it needs to show a component based on what tab was clicked and hide the other component. If the clicked tab is already "active", the component needs to ...
0
votes
1answer
1k views
JSON API call in an Angular service
I have followed this format in my application to call the API and get data from it:
...
1
vote
1answer
157 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, ...
3
votes
2answers
268 views
0
votes
2answers
916 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 <...
0
votes
2answers
665 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 ...