How to clear a model element


#1

I’ve implemented text field that shows an x button when u start typing so that u can click it to clear the field. I’ve managed to figure out how to make the x button show and become clickable etc, and when the click happens I do txtEmail.value = ‘’, however it doesn’t clear the corresponding ng-model. How can I make my clearEmail function clear out the corresponding ng-model as well as the input box?
My HTML:





My Controller:
$scope.showEmailX = function() {
return txtEmail.value !== ‘’;
};
$scope.clearEmail = function() {
txtEmail.value = ‘’;
};


#2

Ok I think I figured this out. In my javascript I can modify the model by just doing $scope.email = ‘’; The model name shows up in the $scope. I was then even able to remove txtEmail.Value = ‘’ since clearing the model automatically updates the element.