根据部分页面动态设置href属性

时间:2016-08-18 18:51:49

标签: angularjs modal-dialog materialize

我有一个index.html页面,上面有一个链接,点击时会显示模态对话框。

<div id="modal1" class="modal">
    <div class="modal-content">
        <h4>Modal Header</h4>
        <p>Modal sample text</p>
    </div>
    <div class="modal-footer">
        <a href="#" class="modal-action modal-close waves-effect waves-green btn-flat">Close</a>
    </div>
</div>

索引页面还显示ui-view内的部分页面:

<div class="" ui-view>

</div>

打开模态的链接位于索引页面上,因此它在任何页面上都可见。我遇到的问题是当单击Close按钮时,模态对话框关闭,然后用户进入登录页面。 这是因为href="#"。为了获取它,页面应该类似于#/page1。因此,必须在用户浏览网站时动态设置。我似乎无法找到一种方法来做到这一点。有人可以帮忙吗?

页面网址如下:

  

http://localhost:77777/index.html#/page1

所以我需要捕获它所在的页面并动态地将它分配给href属性。我怎么能这样做?

1 个答案:

答案 0 :(得分:1)

为什么不使用按钮和ng-click?

类似的东西:

features

在控制器上:

<div id="modal1" class="modal">
    <div class="modal-content">
        <h4>Modal Header</h4>
        <p>Modal sample text</p>
    </div>
    <div class="modal-footer">
        <button ng-click="closeModal()" class="modal-action modal-close waves-effect waves-green btn-flat">Close</button>
    </div>
</div>

希望有所帮助