Skip to content
Advertisement

Tag: angular

How to convert array into a tree structure in javascript

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

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

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

Advertisement