I have two for loops, one nested inside the other. The first loop makes an API call. It will execute for how ever many IDs are selected by the user. I do not have the ability pass more than one ID at a time to the API. The nested loop will run for each object returned by the API and
Tag: angular
How to implement @HostListener(‘window:beforeunload’, [‘$event’]) into canDeactivate guard directives?
In my app, we have lots of components with lots of form fields. So whenever the user changes something in the form and without saving the changes if the user wants to navigate to another component he is getting a warning message using canDeactivate. However, instead of navigating to the app, if the user closes the tab then he is
Generate appropriate Angular Element dynamically without bloating the build size?
Summary: When createCustomElement() is called multiple times inside a switch case, all of the components will be included in the build, instead of just the one that will actually be used. This increases the build size with duplicate code. Details I have an Angular 11 app with a multi-site architecture. There is a project in the angular.json for each site,
How to pass id of object from table to next component?
In the table(table) i have loaded objects from API. When i click on “osavotjad” link i am redirected to another component where i want to load data from selected object. How can i pass id of object what is on the same line with a clicked link. Answer There are many ways to do that. The easiest solution will be
Disable Weekends on ng2-date-picker
I am looking for a function that can disable weekends on my datepicker. I know that I can use isDayDisabledCallback to disable dates but how can I only disable weekends. Answer In the configuration you can set the callback isDayDisabledCallback like that for exclude Saturday and Sunday.
how to display cities in one dropdown based on selected state in other dropdown using json data in angular ionic?
following are my files for html, .ts and json . As json data was very extensive therefore i have just added a few states and their cities. my 1st dropdown is showing all states. Now I want to match my 1st dropdown’s selected value of state with a key “state” in “cities” object in my json file so i can
TypeError: Cannot read property ‘setValue’ of undefined multiple form group
I am using multiple formgroup particular values I need to change data values before submit. but get error TypeError: Cannot read property ‘setValue’ Answer There are multiple ways, but I guess you are looking for this: You basically pass in a path array Another way would be to call get twice, but that can get iffy with a deep path:
Angular template interpolation
Angular version 11 I have a template which uses a method of the typescript file which returns the current date time. The thing is that if in the interpolation of the template I call this method, the first time I render the page, it works properly, but after 1 minute, the value should change to the next minute… which it
Send formArray as one object
I am using mat-stepper single form for my stepper. when i do API call it sends data as an array of objects like this: I would like to send data as one object like this: this is my form: service.ts how can i do it? Answer You can use a simple transformation using javascript reduce function to transform the data
capture error from catchError – http.post
component which is calling submitUser Here is the service file with submitUser function and here is the httpService Post and handleError methods handleError adisplays the console error, I am trying to return/capture this error in my submitUser function in service.ts How do i do that ? Any Inputs appreciated, Thanks Answer Your handleError() method returns an error observable along with