I'm trying to create an number input box that always displays a fixed decimal place (3 decimals for now). So, if a user were to enter the number 1, it would show as 1.000, the value 1.1 would show as 1.100, 1.01 as 1.010, and 1.001 as 1.001.
Searching around it seems like creating an attribute directive to adjust the dom is one solution. And it works fairly well to capture user input. I can not, however, seem to get it to fire when the model is loaded. So, if I had a number variable set to 1 and tied that to my number input box via [(ngModel)], when it loaded it would still show as 1. If I click in the box and then out, the blur event will fire, the directive would run and it would show as 1.000. I've tried attaching the OnInit event to the directive, and I've even trying attaching various lifecycle hooks to the component itself to adjust the element on load, but I can not seem to figure out how to fire the directive directly after angular binds the variable to the input. The value always seems to be blank. The following plnk demonstrate the behavior. https://embed.plnkr.co/L1wxZN8n8tGvWU51KLcj/ Any help/guidance is appreciated. -- You received this message because you are subscribed to the Google Groups "Angular" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. Visit this group at https://groups.google.com/group/angular. For more options, visit https://groups.google.com/d/optout.
