This is my array. I am just trying to frame a hierarchy tree with grandparent->parent->child name relationship. Please help me fix this. Sample input will be like below Expected Output is something like this. Please ignore if any syntax errors Answer You could use reduce and forEach methods to create nested structure and also one array where you can specify
Tag: angular
Highchart not adding new series or removing old series
I am using Angular to show a basic column chart. The idea is to show how many data entries was created by different nodes (This will be received from a web server, but I have removed that code for simplicity for now) I start with showing two basic columns. Then on a button press I change the series so that
How to hide a category when there are no items in it?
I have two arrays in my Angular App, one is an array of object with categories and another array with items which has an object property in it which says to which category the item belong. So i’ve made some custom pipes, one for which return all items if category “all” is selected and other two pipes for items array
Split Function in Angular for a certain combination
I have a string which is like this: or it can be and I want result which should split it like this: The code which I have written: which is producing result like this: What changes should I make in split() function to get the desired result? Answer You can replace rn with something else, then split by n and
Accessing ngx-bootstrap modals outside click event
I’m calling ngx-bootstraps modal from within a ng-template in my applications component. I have built my current setup in a stackBlitz example As you can see, I have added another event to the modals cancel/close button – when these are clicked two events fire. One to close the modal and another to do “something else”. I want to be able
change file name in angular when download that by “Blob”
i want to download file from server in angular : this code from service: and this code for download that file in brwoser: but i have a problem with that , when i downlaod file , file name is this [object Blob] but i want to download by orginal name for example if file is file1.jpg , when downloaded file
Cookie value undefined in angular 6+
i am using angular and node js. i use “CookieService” package token.service.ts class trying to use token service in my streams.component.ts but i got undefined in “GetToken” here is my Streams.component.ts please help me out to solve this. Answer you just forgot to return the token
How to display the template based on the roomList data using ngTemplateOutlet in angular
TS HTML < How to display room template based on the roomList name. for example ‘Room2’ then in ngTemplateOutlet will display the template of Room2. Answer You need to create TemplateRef and refer that in the html using this DEMO
Return Observable From Promise That Gets Rejected
I’m trying to determine how/if I can convert a Promise rejection into a typed Observable. I have a login component with a function like this… and an authentication service with a method like this… How can I return an Observable<Credentials> if the Promise resolves, and bubble up the error if it rejects? I know I can make everything work if
How can I generate FormControls dynamically inside a FormGroup?
I am receiving an object from the db that contains a few elements with the following format: To work with those “dias” array and include inputs to modify each value in case the user wants to, I’ve manually created a FormGroup containing a formControl for each of those days (the real object contains up to 8 days). And then, in