Reputation: 1275
Is it possible to save state (entered text) of the input when collapsing ngb-accordion?
Here is example: https://stackblitz.com/edit/angular-ukshlz-wz6st8?file=app/accordion-basic.html
If you enter some text into input and collapse / expand first panel then input loose it's contents.
Upvotes: 1
Views: 1276
Reputation: 57939
just use a variable and ngModel
myinput:any; //in your .ts
<input [(ngModel)]="myinput"> //your .html make use of the variable
Updated made by @tilias
if you use complex component structure, another possibility is setting destroyOnHide to false
<ngb-accordion [destroyOnHide]="false">
This will prevent destroying component, which holds your input and it's binding: see the docs
while I updated the answer, Tilias found the correct solution: remove my update
Upvotes: 3