0

I have an input tag

                                    <div class="form-group" ng-form name="patientLinkingForm">
                                        <input type="text" class="form-control"
                                               ng-model="formData.parameters.otherRelationshipText" ng-pattern="/^[a-zA-Z. ]+$/" maxlength="100" name="otherRelationshipText">
                                        <span ng-show="patientLinkingForm.otherRelationshipText.$error.pattern"> my msg </span>
                                    </div>

and a button outside the div.

                        <button class="btn btn-primary btn-space" id="patientLinkingSM_linkBtn">
                                my button
                        </button>

Now I want to display the message in span only when the button is clicked , and I am using angular js form validation without the actual html form.

Please help me how to display the span when the button is clicked. I can do that with $submitted if my div is in html form tag here I have done that it worked.

 <span ng-show="myform.$submitted && myform.otherRelationshipText.$error.pattern"> my msg <span/>

But now there is no html form defined , how to do it without html form tag.

Thank you.

2
  • As I understand correctly, you can just add to controller some variable eg. buttonClicked and then set it to true in the template on button click: ng-click="buttonClicked=true, and then just change condition on ng-show to ng-show="buttonClicked && .... Am I right? Commented Jan 18, 2021 at 16:36
  • Hy Thankyou so much @FaustynPiechowiak for the idea. Commented Jan 20, 2021 at 6:27

0

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.