Angular 4:表ng-if值等于行标题

时间:2018-01-29 22:58:38

标签: javascript angular typescript html-table ngif

我需要一些帮助...我想创建一个如下图所示的表格。当列的名称与行“header / name”匹配时,它应该显示一些值,如“1”或“x”。

https://imgur.com/AZkt3bd "Description"

<table class="thead-dark">
    <tr>
      <th class="pointer">
        Name
      </th>

      <th class="pointer" *ngFor='let item of applicationlist'>{{item.AName}}
      </th>
    </tr>
    <tr *ngFor='let item2 of liste'>
      <th class="pointer">{{item2.AName}}</th>
      <td *ngFor='let item of applicationlist'>{{item2.HApllication}}</td>
    </tr>
</table>

我的.ts文件的一部分

bestfuncever() {
    const rootRef = firebase.database().ref();
    const maintable = rootRef.child('/BFunctions/').orderByChild('CFlag').equalTo('active');
    maintable.on('child_added', snap => {


      if (snap.val()) {
        this.liste.push(snap.val());
      }
      console.log(this.liste)
      let BFuncGBProcess = rootRef.child('BFunctions/' + snap.key + '/HApllication');
      BFuncGBProcess.once('value').then(Processes => { 
        if (Processes.val()) {
          this.Processlist.push(Processes.val())};
        let BProess = rootRef.child('Application/' + Processes.val());
        BProess.once('value').then(Applications => {
          if (Applications.val()) {
            this.applicationlist.push(Applications.val());
              console.log(this.applicationlist)
          }
        })
      })
    })
  }

1 个答案:

答案 0 :(得分:2)

好的,我自己以某种方式做到了! <ng-container *ngFor='let item of applicationlist'> <td *ngIf="item.AName==item2.HApllication; else wrong">1</td> <ng-template #wrong><td>0</td></ng-template> </ng-container>