Dynamically loading columns and data in to table in Angular 2

后端 未结 7 884
醉话见心
醉话见心 2020-12-19 09:18

I have an HTML page in which I want to create a table. The columns in this table are dynamic which means that they are fetched from the server into a variable in the compone

7条回答
  •  伪装坚强ぢ
    2020-12-19 09:50

    My solution is use Input() to give column and rows as array into data table component, it only renders that columns and rows i want to see:

    in component:

      @Input('cols')
      set cols(value: string){
        this._cols = value;
      }
      get cols(){
        return this._cols;
      }
    
      Input('rows')
      set rows(value: string){
        this._rows = value;
      }
      get rows(){
        return this._rows;
      }
    

    in view:

    
    

提交回复
热议问题