ng-href在按钮中不起作用。 angularjs 1.7

问题描述 投票:0回答:1
<button ng-href="#!/edit/{{a.id}}" 
        type="button" 
        class="btn btn-default btn-sm">
    <span class="glyphicon glyphicon-edit"></span> 
    Edit
</button>

单击按钮时没有任何反应。但如果我使用它,它会转到我想要的链接

<a ng-href="#!/edit/{{a.id}}> Edit </a>

如何使用按钮进行此路由?谢谢

angularjs
1个回答
1
投票

问题是<button>元素不支持href属性。

您可以尝试的是使用Bootstrap类将<a>元素设置为按钮。

<a ng-href="#!/edit/{{a.id}}"
   class="btn btn-default btn-sm">
    <span class="glyphicon glyphicon-edit"></span>
    Edit
</a>
© www.soinside.com 2019 - 2024. All rights reserved.