You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Allow "defaulting" empty input values without having to write your own inputTransformFn.
For instance
[defaultInputValue]="0"
[defaultInputValue]="1"
Describe the solution you'd like
The issue we're running into is, some of our fields cannot be left empty/blank - such as a quantity field, can only be positive integers > 0.
Or price/cost fields can be any numeric value but cannot be undefined.
I wrote an output transform fn to catch that scenario and write 0 back to my model and it is working beautifully, however the field appears blank on blur.
I know I can write my own inputTransformFn but once I write my own, the directive's own mechanism for sanitizing is no longer leveraged (which works great btw) and I'm force to roll my own solution.
Ideally what I'd like is one of two things, an I apologize if I misunderstood something and this can easily be done today.
Set a default "input" value so when empty it'll fall back to that value.
or
Use existing directive's string sanitization mechanism in my own custom written inputTransformFn that will scrub/remove non-numeric and special characters before my logic to check for empty/falsy and returning "1" or "0" depending on case.
Example
In this SB - if you provide a numeric value then blur - the appropriately formats the input string and updates the model as expected.
If you highlight the value in the field and remove it, and blur - 0 will get written to the model but the field remains empty. My hopes would be in this case that it would appear as "0.00"
I would welcome this feature. In my case, I want the default value to be null for <input name="limitValue" type="text" matInput mask="separator" [(ngModel)]="item.limit.value">
However, I currently have an empty string, but the backend only accepts numbers or null.
🚀 feature request
Description
Allow "defaulting" empty input values without having to write your own inputTransformFn.
For instance
[defaultInputValue]="0"
[defaultInputValue]="1"
Describe the solution you'd like
The issue we're running into is, some of our fields cannot be left empty/blank - such as a quantity field, can only be positive integers > 0.
Or price/cost fields can be any numeric value but cannot be undefined.
I wrote an output transform fn to catch that scenario and write 0 back to my model and it is working beautifully, however the field appears blank on blur.
I know I can write my own inputTransformFn but once I write my own, the directive's own mechanism for sanitizing is no longer leveraged (which works great btw) and I'm force to roll my own solution.
Ideally what I'd like is one of two things, an I apologize if I misunderstood something and this can easily be done today.
or
Example
In this SB - if you provide a numeric value then blur - the appropriately formats the input string and updates the model as expected.
If you highlight the value in the field and remove it, and blur - 0 will get written to the model but the field remains empty. My hopes would be in this case that it would appear as "0.00"
https://stackblitz.com/edit/stackblitz-starters-byub7y?file=src%2Fapp%2Fapp.component.ts
The text was updated successfully, but these errors were encountered: