jsdude jsdude - 6 months ago 15
AngularJS Question

How do you clear form inputs when a model changes in AngularJS?

I have a form that has some common inputs and inputs that are specific to a model 'type'. When a user selects a certain 'type', from a select dropdown, these specific fields change. I'm using ng-include to include the specific 'partial' based on model.type. In 'edit' mode, how can I reset these specific inputs when the model 'type' changes?


Use an ng-change property on the select.

Then tie it to a function which clears the models that are bound to your form inputs (e.g. sets to '').