根据部分页面动态设置href 属性
Setting href property dynamically based on partial page
我有一个 index.html 页面,上面有一个 link,单击时会显示模态对话框。
<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>
打开模式的link在 中的索引页上,因此在任何页面上都可见。我遇到的问题是单击 Close
按钮时,模式对话框关闭,但随后用户被带到登录页面。
发生这种情况是因为 href="#"
。为了让它被采用,页面应该类似于 #/page1
。所以它必须在用户浏览网站时动态设置。我似乎无法想出办法做到这一点。有人可以帮忙吗?
页面 url 是这样的:
所以我需要捕获它所在的页面并将其动态分配给 href
属性。我该怎么做?
为什么不使用按钮和 ng-click?
类似于:
<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>
在控制器上:
$scope.closeModal = function(){
//your code to close the modal window
}
希望对您有所帮助
我有一个 index.html 页面,上面有一个 link,单击时会显示模态对话框。
<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>
打开模式的link在 中的索引页上,因此在任何页面上都可见。我遇到的问题是单击 Close
按钮时,模式对话框关闭,但随后用户被带到登录页面。
发生这种情况是因为 href="#"
。为了让它被采用,页面应该类似于 #/page1
。所以它必须在用户浏览网站时动态设置。我似乎无法想出办法做到这一点。有人可以帮忙吗?
页面 url 是这样的:
所以我需要捕获它所在的页面并将其动态分配给 href
属性。我该怎么做?
为什么不使用按钮和 ng-click?
类似于:
<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>
在控制器上:
$scope.closeModal = function(){
//your code to close the modal window
}
希望对您有所帮助