I'm trying to refresh and concatenate a string when multiple checkboxes is checked.
For example, when 'apple'
and 'banana'
are checked, $scope.strin
g should be ='ab'
, then when 'banana
' is unchecked, $scope.string
should be left with 'a'
.
What I did does concatenate, however $scope.string won't remove old values, it is still ='aba'
Here is my attempt on JsFiddle.
You can see when all checkboxes are checked it gives me aababcabcd
Thanks
I've updated your code: http://jsfiddle.net/d3ruexuv/1/
The text isn't clearing because you were only appending the items to the current value, not creating a new string altogether. You can see now that an empty string is always created first:
var newText = "";
and selected items concatenated to that
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With