How to generate dynamic component from Typescript file?

#1

I have json data as following:

{
  "ABC": "1236565",
  "nrp_data":{
       "passenger":[
           {
            "BType":"KC",
            "BStatuss":"FN"
           },
           {
           "BType":"LP",
           "BStatuss":"KN"
           }
        ]
   }
}

Now In passenger I have 2 data(it could be dynamic) and I want to display them in ion-label? I am getting count by
var count = Object.keys(data.nrp_data.BType).length;
So based on the count I want to display those data in Label. Sometime data could be 4 or 5 How do I achieve this? Any help would be appreciated. Thanks!

#2

You are thinking about this backwards. You don’t generate components from controllers. You use structural directives in templates to iterate across lists that live in the controller, and then what you think of as “generating a dynamic component” is done by simply adding elements to that list. See the Tour of Heroes for more info.