简体   繁体   中英

AngularJS - How to make a button inside an anchor tag?

I've made the next html code -

    <a  class="list-group-item">
       <p class="list-group-item-text"></p>
 <p class="btn btn-info"  href="javascript:;" ng-click="onclick(alert('Hello world!'));">Hi world</p>
    </a>

How can I make the

with the 'btn' class be clickable? (meaning see the hello word alert)

Thanks for any kind of help

From your sample it looks like you're trying to use an anchor element to have a list of text and following buttons? Why not just put the ng-click on the Anchor element and apply the bootstrap class of btn to that?

I do believe the issue you have with your sample is that the anchor is catching the click event as opposed to the nest

element, as they're not meant to be used as containers.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM