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;
}``` Temp is not working although it is const, in my html it does not work!. I think although i make it 0 but it changes to undefined another funney thing is i have this meessage " Temp' is declared but its value is never read". here is my html:
<li *ngIf="licensePackage && licensePackage.id===100" >
<a routerLink="kpi-view" routerLinkActive="active">
<div class="tw-w-3 tw-float-right -tw-mt-3" *ngIf="Temp===0">
<mat-icon svgIcon="alerts_outlined" class="tw-max-w-3" aria-hidden="true"></mat-icon>
</div>
summary
</a>
</li>
#const does not work!
12 messages · Page 1 of 1 (latest)
const/let variables only live in their context. And that's not the component root. You need to assign the value to a new variable created at your component root.
g!codeblock @cinder finch
@cinder finch, you can use the following snippet to have your code formatted and colored by Discord. Replace ts with the language you need (i.e. html, js, css, etc)
```ts
// your code goes here
```
Outside of your third if block, Temp doesn't exist.
ok @agile pike , i got you, thanks, so how should i have global var? should i declare public static Temp: number? in the beginnig of this file?
Thank you @agile pike but my problem is the html file which i need to control an element in it is for a component but i am having and filling out the Temp in one "service".
Mind without explicit context, it was obvious html and ts were about the same component.
Given the situation I encourage you the official Angular tutorial as it showcases component/service communication.
g!toh @cinder finch
@cinder finch The place we recommend starting your Angular journey is with the Tour of Heroes tutorial, located here https://angular.io/tutorial.