Clear an input field on form submit in Angular?
angularjs
Solution
Gonna leave this here, since that other question is poorly named for finding the solution to this problem.
You have to manually clear the values of the form elements.
For example, if you have:
input#project_name(ng-model="project.name", type="text")
To empty it you could do:
$scope.project = null
in your controller.
Problem
I've gathered that $setPristine is supposed to do this, but it isn't on my project. This is my form: ``` form(name="new_project", ng-submit="create_project()") div.create_wrapper input#project_name(required, ng-model="project.name", type="text") select#project_language(required, ng-init="project.language='PHP'", ng-model="project.language", ng-options="language for language in languages") input.button.tiny.radius(type="submit", value="Create") ``` And the js: ``` $scope.create_project = () -> project = new projectFactory this.project project.$save project, (form_data) -> $scope.projects.push form_data $scope.new_project.$setPristine() ``` There are no errors, and pristine is set to true, but the inputs value remains.