R
R
rohan_rohan2021-07-14 12:59:15
Angular
rohan_rohan, 2021-07-14 12:59:15

How to output object of objects in angular?

Good afternoon!
There is an object inside which there are other objects, and inside them there are more objects. Can you tell me how to display key values ​​using *ngFor?

const data = {
        first_data: {
          id: "1",
          name: "First",
          type: "Administration",
          sections: {
            main_section: {
                id: "main_section",
                name: "Main Section",
                sub_sections: {
                    sub_first: {
                        id: "12",
                        name:  "Subsection_name",
                        questions: {
                          first_question: {
                            id: "44",
                            name: "Answer"
                          },
                          second_question: {
                            id: "33",
                            name: "True"
                          }
                        }
                      }
                    }
                  }
                }
              }
            }

Answer the question

In order to leave comments, you need to log in

2 answer(s)
N
nuclear_kote, 2021-07-14
@nuclear_kote

a recursive function must be written either through the stack. pure ngFor in any way

P
Piratt14, 2021-07-16
@Piratt14

If you just need to display data with formatting, then the pre tag and the json pipe will do just fine.
It works like this {{ data | json}}

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question