【问题标题】:How to use Bootstrap button-group and AngularJS to navigate between pages如何使用 Bootstrap 按钮组和 AngularJS 在页面之间导航
【发布时间】:2016-01-06 04:50:14
【问题描述】:

我有这部分代码可以创建一个按钮组:

<div class="btn-group btn-group-lg">
    <button id = "Image" type="button" class="btn btn-primary">Click1</button>
    <button id = "Text" type="button" class="btn btn-primary">Click2</button>
</div>

我想让它动态化,从某种意义上说,每个按钮都会将我带到不同的 URL。我遇到了这个帖子:

How do I navigate to another page on button click with Twitter Bootstrap?

但是,在处理按钮组时我不能使用&lt;a&gt;&lt;/a&gt;(或者至少想不出这样做的方法)。所以我想我需要一个带有函数的 JS 文件?我如何使用 AngularJS 做到这一点?

【问题讨论】:

    标签: javascript html angularjs twitter-bootstrap


    【解决方案1】:

    您可以使用简单的 Javascript 函数,例如:

    go(path) {
        window.location = path;
    }
    

    然后从你的按钮调用它:

    ng-click="go('index.html')"
    

    【讨论】:

    • 我已将整个 html 定义为 angularjs 应用程序。这不是问题吗?我还能使用基本的 html 命令吗?我问这个是因为点击显示为未定义。可能是角度定义,或者可能是因为它位于引导按钮内?不太确定,因为我对这一切都很陌生。
    猜你喜欢
    • 2022-11-22
    • 2014-04-24
    • 2021-05-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-06-21
    • 1970-01-01
    • 2014-12-14
    相关资源
    最近更新 更多