Home > Blockchain >  const var does not keep its value
const var does not keep its value

Time:10-18

if (dashboardConfiguration.widgets.filter(w=>{
        return w.widgets.filter((wid)=>{
                if(wid.extension === WidgetExtension.Score){
                     if(this.IsInvalidValidScoreWidget(wid)){
                        wid.isValid = false;
                       const Temp=0;
                        return wid;
                         }
                     else{
                       const Temp=1;
                     }
                } 
                
        });
    }).length >0){
        results.set('widget', false);
        results.set('valid', false);
    }

    return results;
   
}

and my temp does not work so my *ngIf does not work although Temp is const. Actually I need to show the mat-icon when Temp is 0. Would you please help? here is my html and I am filling out the Temp in a service but by its value i am trying to control my html elemnt.

<li *ngIf="licensePackage && licensePackage.id===100"  >
        <a routerLink="kpi-view" routerLinkActive="active">  
            <div   *ngIf="Temp===0">
                <mat-icon svgIcon="alerts_outlined"  aria-hidden="true"></mat-icon>
            </div>
            {{'menu_Summary_View' | translate}}
        </a>
    </li>

CodePudding user response:

For temp to work correctly, you must declare it in your class instead of your function like this:

export class myClass {

   public temp : Number;
   ...

}

then in the if: this.temp = 0

CodePudding user response:

you can have two methods in service. one for your normal data returns and another one for Temp value. or

you can add the value of Temp in the results (i.e. results.set('Temp', Temp);)

  • Related