Hide 'Zero' value in input using typescript and Angular 2

hide hiding
animal hide synonym
hide juice wrld
hide lyrics
hide movie
animal hide definition
hide game
hiding from someone
<input type="text" class="form-control"
                   id="transactionAmount"
                   maxlength="10"
                   OnlyNumber="true" 
                   [(ngModel)]="userBalance.transactionAmount" 
                   name="transactionAmount"
                   placeholder="Amount"
                   required
                   #transactionAmount="ngModel">
  1. Here I have to hide zero amount while user entering the values.
  2. If he enters all zero's then only we have to hide not in cases like 20,30,100 etc...
  3. I'm using Angular 2.
<input type="text" class="form-control"
               id="transactionAmount"
               maxlength="10"
               OnlyNumber="true" 
               [(ngModel)]="userBalance.transactionAmount" 
               name="transactionAmount"
               placeholder="Amount"
               required
               #transactionAmount="ngModel"
               (keyup)="hideZero()>

Added This keyUp event in Html and in .ts added below code

hideZero(){
if(this.userBalance.transactionAmount === '0' ){
    this.userBalance.transactionAmount = '';
}

}

Working Absolutely fine

Hide, a camouflaged shelter used to get a close view of wildlife. Definition of hide (Entry 2 of 5) hide or hair or hide nor hair : a trace or visible sign of someone or something a wife he hadn't seen hide or hair of in over 20 years — H. L. Davis verb (2)

/* In your ts */
validateNumber(value: String) {
 userBalance.transactionAmount = value && value.replace(/(?:0*)(\d*)/g, (_,value1) => {
 return value1;
})
}
<input (input)="validateNumber($event)">

Hide (TV Movie 2011), (Entry 1 of 5) transitive verb. 1a : to put out of sight : secrete hide a key under the doormat. SYNONYMS FOR hide 1 screen, mask, cloak, veil, shroud, disguise. Hide, conceal, secrete mean to put out of sight or in a secret place. Hide is the general word: to hide one's money or purpose; A dog hides a bone.

Try using (ngModelChange) event which will trigger when user types values. By using regex, you can remove the last zero value and update the DOM. Hope this helps.

hide, Hide is the general word: to hide one's money or purpose; A dog hides a bone. Conceal, somewhat more formal, is to cover from sight: A rock concealed them from  Define hide. hide synonyms, hide pronunciation, hide translation, English dictionary definition of hide. conceal; cache; stash: Hide the money under the mattress

.hide(), VerbEdit. hide (third-person singular simple present hides, present participle hiding, simple past hid, past participle hidden or (archaic)  Directed by John Gray. With Carla Gugino, Mark-Paul Gosselaar, Kevin Alejandro, Bridget Regan. A Boston detective investigates the mummified remains of six women, based on a novel by Lisa Gardner.

HIDE, hide();. The matched elements will be hidden immediately, with no animation. This is roughly equivalent to calling .css( "  95 synonyms of hide from the Merriam-Webster Thesaurus, plus 229 related words, definitions, and antonyms. Find another word for hide. Hide: to put into a hiding place.

Hide, to put something or someone in a place where that thing or person cannot be seen or found, or to put yourself somewhere where you cannot be seen or found: She  Directed by K.C. Bascombe. With Rachel Miner, Christian Kane, Polly Shannon, Beth Grant. A modern day Bonnie and Clyde - with a twist - that follows two lovers down a path of destruction, mayhem, and murder as they live in a world where it is acceptable to take whatever they want with murderous consequences.

Comments
  • call a function on change event, where you patch null to that input if the value entered is all 0s
  • what have you tried so far?
  • @Faisal tried patterns but it didn't work
  • @MohdTabishBaig I'm using change event and ill let you know if its worked or not
  • Maybe your answer is here? stackoverflow.com/questions/27916185/…