1

I used angular 7 and ngx-treeview. I want to change text color of item if some condition is verified.

this is my html file :

<ng-template #itemTemplate let-item="item" let-onCollapseExpand="onCollapseExpand" let-onCheckedChange="onCheckedChange">
      <div class="form-inline row-item">

        <i *ngIf="item.children" (click)="onCollapseExpand()" aria-hidden="true" class="fa" [class.fa-caret-right]="item.collapsed"
          [class.fa-caret-down]="!item.collapsed"></i>
        <div class="form-check">
          <input type="checkbox" class="form-check-input" [(ngModel)]="item.checked" (ngModelChange)="onCheckedChange()" [disabled]="item.disabled"
            [indeterminate]="item.indeterminate" />
          <label class="form-check-label" (click)="item.checked = !item.checked; onCheckedChange()">
            {{item.text}}
          </label>

        </div>
      </div>
    </ng-template>

    <div class="row">
      <div class="col-6">
        <div class="form-group">
          <div class="d-inline-block">
            <ngx-treeview [items]="items" [itemTemplate]="itemTemplate" (selectedChange)="onSelectedChange($event)">
            </ngx-treeview>
          </div>
        </div>
      </div>

    </div>

and this this my function which allows to fill the treeview component:

let bookObjects = new Array();
        this.testService.query({

      }).subscribe((res: HttpResponse<TestEntity[]>) => {
        this.temp= res.body;

        this.temp.forEach((x) => {


          if(x.nbr=='0')
            {
               x.     // here should normaly render the text in order to change the color
            }




            bookObjects.push(new TreeviewItem(x));
            });


      });

the solution is to know how to render the text of each item.

franco
  • 1,829
  • 6
  • 42
  • 75

0 Answers0