jsdude jsdude - 1 year ago 53
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?

Answer Source

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 '').


Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download