Build an Angular component that takes a tree-like data structure (key β children array
) and displays it as a properly indented hierarchy using nested <ul>
and <li>
lists.
The component should work with the following tree object:
const tree = {
"a": ["b", "c"],
"b": ["d", "e"],
"c": ["f", "g"],
"e": ["h", "i"],
"f": ["j", "k"]
};
π Expected Output
The tree should be rendered as:
a
- b
- d
- e
- h
- i
- c
- f
- j
- k
- g
π How to Run
Clone this repository:
git clone https://github.com/cvishalgit/tree-assignment.git
Navigate into the project:
cd tree-assignment
Install dependencies:
npm install
Run the Angular development server:
ng serve
Open your browser and go to:
http://localhost:4200
π Project Structure
tree-assignment/
β-- src/
β βββ app/
β β βββ app.component.ts
β β βββ app.component.html
β β βββ app.component.css
β β βββ ...
β βββ index.html
β βββ styles.css
βββ angular.json
βββ package.json
βββ tsconfig.json
βββ README.md