How to set a variable value inside of a ionic template?

I want to declare a variable and set a value in my IONIC app Template file. The variable may used singly or in a foreach iteration. I already got some solution but solutions are not working.
I tried as following…

{{flag = true; ""}}

another is using ng-init

<div *ngFor="let item of items" ng-init="myVariable = 'something...'">
  {{myVariable}}
  ...
</div>

So, I can not set variable and it’s value in ionic template. Please give me a solution which is actually working.

why do you want to set a value like this?

1 Like

as per application logic I need to active flag or set others variable value on the basis of api data.

Have a look at this.