Search code examples
javascriptangulartypescripthtml-tableangular-ng-if

Angular 4: Table ng-if value equals row header


I need some help please... I want to create a Table like the one in following picture. It should show some values like "1" or "x" when the name of the column matches the row "header/name".

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>

part of my .ts file

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)
          }
        })
      })
    })
  }

Solution

  • Ok, i somehow did it by myself! <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>