2

Hi I have form where I am using many fields. After submitting and if everythign goes fine I am clearing or setting form to default state but I am still getting error message.

<div>
        <span>Type:</span>
        <select class="chosen" name="type" required="" chosen="exp.transactionType" ng-model="exp.selectedTransactionType"
            ng-options="tt.value for tt in exp.transactionType">
        </select>
        <div class="error-msg" ng-show="form.$submitted || form.type.$touched">
            <span class="error-msg" ng-show="form.type.$error.required">Select transaction type.</span>
        </div>
    </div>

Am i doing something wrong here?

1 Answer 1

1

You need to set pristine of your form. Lets say your form name is "myForm", so just after clearing your form, you can do the following

$scope.myForm.$setPristine();
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.