I recently developed an Angular component that consists of a button and an icon.
One key requirement is for each instance of this component to retain its own status.
For example, let's say we have three instances in the app.component.html:
<app-view-btn></app-view-btn>
<app-view-btn></app-view-btn>
<app-view-btn></app-view-btn>
Now, here is the code for the view-btn-component:
view-btn-component.html
<button>
<i
class="fa"
[ngClass]="status ? 'fa-eye-slash' : 'fa-eye'"
aria-hidden="true"
(click)="clickEvent()">
</i>
</button>
view-btn-component.ts
status: boolean = false;
constructor() {}
ngOnInit(): void {}
clickEvent(){
this.status = !this.status;
}
The current issue I am facing is that when the page reloads, the components lose track of their statuses.
Can anyone suggest how I can implement a solution where each component retains its status using local storage or any other method?