Adding rows with ng-repeat and nested loop

前端 未结 6 925
情书的邮戳
情书的邮戳 2020-12-02 15:25

I\'m looking for a way to add rows to a table. My data structure looks like that:

  rows = [
    { name : \'row1\', subrows : [{ name : \'row1.1\' }, { name          


        
6条回答
  •  隐瞒了意图╮
    2020-12-02 16:03

    Here is an example. This code prints all names of all the people within the peopeByCity array.

    TS:

    export class AppComponent {
      peopleByCity = [
        {
          city: 'Miami',
          people: [
            {
              name: 'John', age: 12
            }, {
              name: 'Angel', age: 22
            }
          ]
        }, {
          city: 'Sao Paulo',
          people: [
            {
              name: 'Anderson', age: 35
            }, {
              name: 'Felipe', age: 36
            }
          ]
        }
      ]
    }
    

    HTML:

    {{ person.name }}

提交回复
热议问题