Robert
Robert

Reputation: 167

AngularJS does not like the a tag

Problem: I have the following code which works fine:

<div style="margin-top: 5pt;">
     <a href="{{e.DocURL}}" target="_blank">
         <button class="btn btn-primary" 
                 id="showDocs" 
                 ng-show="e.DocFlag === 'Y'" 
                 style="border-radius: 13px; padding-bottom: 5px;" 
                 type="button">Provider Bio
         </button>
     </a>
</div>

However, whenever I update the form, the a tag goes disappears. I'm still fairly new to AngularJS and is their a alternative to the a tag I can use.

Upvotes: 0

Views: 41

Answers (2)

Niles Tanner
Niles Tanner

Reputation: 4021

Your a tag is not disappearing your button is. Look at this line:

ng-show="e.DocFlag === 'Y'" 

When e.DocFlag is anything other than 'Y' the button will disappear. The button is the only thing inside the a tag. when there is nothing inside the a it will appear to be gone.

Upvotes: 0

Fabien M&#233;nager
Fabien M&#233;nager

Reputation: 140195

I think you should not wrap the button with an <a> but put the "btn btn-primary" class in the <a>. HTML may not allow a link to contain a button.

Edit: This is confirmed by this answer: Can I nest a <button> element inside an <a> using HTML5?

Upvotes: 1

Related Questions