I have build 2 route in my Angular 7 apps,
{
path: 'create',
component: CreateComponent
},
{
path: 'view',
component: ViewComponent
}
they are both lazily loaded, in CreateComponent
there is a form with many form fields in it, and same thing happen with the ViewComponent
.
The problem is, whenever i go to /view
route or ViewComponent
from /create
route or CreateComponent
, all of the form fields inside previous component (i.e. ViewComponent
) were returned to initial state (i check it by returning to /create
route again), in other word the form fields got automatically reset, and the same thing happened if I went from /view
route to /create
route, all the form fields in /view
were reset by angular automatically.
So, how to fix this problem? I want to keep all the form fields keep its previous value (even though the form weren't submitted yet) if i change or go to another routes.
Thanks,