Ritu Singh
Query: How to Force the input field to return to the former correct value on wrong input in Angular
Problem
My app.component.html goes like this:
and my app.component.test goes like this:
If I launch the app, type 5 in the field, hit enter, type -3 in the field, hit enter, I would like the field's content to return to 5, the former correct value.
How do I achieve this? I tried adding else { this.myValue = this.myValue} after the if to simulate a change and force a reloading of the view but that doesn't work.
Solution
Ok to use another state to maintain the previous successful input? Not tailored to Angular, so you'll have to modify it as needed...
Suggested blogs:
>How to make the dropdown for this button ADA accessible in Angular?
>How to update properties value with event in template Angular?
>Unit Test Angular Standalone Component, Overriding Provider not used
>How to Import componet's own module using Angular?
>Why component does not display variable of another component in Angular?
>What are the ways to pass parameters to Angular service?
>How to access variables in a function using Angular?
>How can I close a bootstrap modal using Angular?
>Fix: Strange compilation error with Typescript and Angular
>Uploading files and JSON data in the same request with Angular
>CRUD Operations In ASP.NET Core Using Entity Framework Core Code First with Angularjs
>A Complete Guide To Angular Routing