在线观看不卡亚洲电影_亚洲妓女99综合网_91青青青亚洲娱乐在线观看_日韩无码高清综合久久

鍍金池/ 問答/HTML5/ (angular)如何構(gòu)建一個活的顯示組件,后臺傳回任意類型的list對象

(angular)如何構(gòu)建一個活的顯示組件,后臺傳回任意類型的list對象

目前單層對象也可以通過下列方式解決

class  Person{
    constructor(private name: string, private age: number,private describe: string){}
}


function main(): void {
   let persons = new Array<Person>();
   persons.push(new Person('aa',11,'bb'));
   persons.push(new Person('aa',11,'bb'));
   persons.push(new Person('aa',11,'bb'));
   persons.push(new Person('aa',11,'bb'));
   persons.push(new Person('aa',11,'bb'));
   persons.push(new Person('aa',11,'bb'));
   persons.push(new Person('aa',11,'bb'));

   showField(persons);
}

function showField(datas :Array<any>): void{
    for(let fi in datas[0]){
        console.log(fi + datas[0][fi]);
    }
}

main();
回答
編輯回答
練命

謝邀。

<div [ngClass]="containerClasses" [ngStyle]="containerStyles">
    <ng-container *ngFor="let opt of options?.children">
         <ng-container *ngIf="opt  && opt.selector && opt.options">
              <component1 *ngIf="opt.selector === 'component1'" [options]="opt.options">            
              </compnent1>
              <component2 *ngIf="opt.selector === 'component2'" [options]="opt.options">            
              </compnent2>
              ...
              <ng-container *ngFor="let subopt of opt.children">
                  <ng-container *ngIf="subopt && subopt.selector && subopt.options">
                      <component3 *ngIf="subopt.selector === 'component3'"[options]="subopt.options">            
                      </compnent3>
                      <component4 *ngIf="subopt.selector === 'component4'" [options]="subopt.options">            
                      </compnent4>
                      ....
                  </ng-container>
              </ng-container>
         </ng-container>
    </ng-container>
</div>
                

以上代碼實現(xiàn)了一個多層動態(tài)組件的container,你需要什么組件,只要把它放到container下面就可以了。
歸根到底,就是維護一個options的對象。

2018年6月1日 16:59