How to create a backspace button in ionic


#1

I want to create a backspace button in ionic when clicking on that button the length of the string should reduce by one…

I tried the following–

clear()
{

this.value=this.value.length-1;
}

but in this case the output is the length of the value minus one,
like if input is 123 ,I am getting output on clicking the button as 2(length=3-1)
as ,my output…
Please help if anyone has tried this out…
Thanks,


#2

.lenth measures the length of stuff. You have to use the calculated valued to cut string in length.


#3

How can i do this… Please elaborate…


#4
this.value = this.value.substr(0, this.value.length-1);

#5

Thanks a lot…it works fine :slight_smile: