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.

Ishmeet Singh
  • 109
  • 1
  • 2
  • 10
  • 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? – Faustyn Piechowiak Jan 18 '21 at 16:36
  • Hy Thankyou so much @FaustynPiechowiak for the idea. – Ishmeet Singh Jan 20 '21 at 06:27

0 Answers0