Angular UI bootstrap 使用 location.path 函数后的模态重定向
Angular UI bootstrap modal redirect after function using location.path
用户在此模式中单击“确定”后,应将他们带到另一个页面。我在我的 app.js 中有路由,在我的控制器中有我的功能,在我的模态视图中,但它只是继续将用户带到“#/home”,而不是其他地方。不确定为什么会这样或如何解决它。有任何想法吗?
我的代码:
模式视图:
<!-- Recur Confirm Modal -->
<div class="modal fade" id="recurConfirm" tabindex="-1" role="dialog" aria-labelledby="recurConfirm" aria-hidden="true">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-body">
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">
×
</button>
<p>Congratulations! Your recurring claim has been submitted and will be reviewed by our customer service team. We’ll contact you if we have any questions or concerns with your submission. If you have questions about your submission, please contact our customer service team at (800) 669-3539 or <a class="naviaLink" href="mailto:customerservice@naviabenefits.com">customerservice@naviabenefits.com</a>.</p>
</div>
<div class="modal-footer">
<input type="button" class="naviaBtn naviaBlue" data-dismiss="modal" value="okay" ng-click="recurOkay()">
</div>
</div>
<!-- /.modal-content -->
</div>
<!-- /.modal-dialog -->
</div>
<!-- /.modal -->
我的控制器函数(当用户保存数据然后进行重定向时触发此模式):
$scope.recurOkay = function() {
$('#recurConfirm').modal('hide');
$('body').removeClass('modal-open');
$('.modal-backdrop').remove();
$location.path('/#/pptHome');
};
而且我的路线很标准。
$location.path
方法仅接受 URL string
,该字符串不应包含 #
。基本上,此方法将在 URL
.
中的 #
之后追加给定的 string
所以在你的情况下 $location.path('/#/pptHome');
执行后,它重定向到路由引擎无法识别的 URL http://localhost/#/#/pptHome
并重定向到回退 URL .
要解决此问题,请执行以下操作。
$location.path('/pptHome'); //will redirect to `/#/pptHome`
用户在此模式中单击“确定”后,应将他们带到另一个页面。我在我的 app.js 中有路由,在我的控制器中有我的功能,在我的模态视图中,但它只是继续将用户带到“#/home”,而不是其他地方。不确定为什么会这样或如何解决它。有任何想法吗?
我的代码:
模式视图:
<!-- Recur Confirm Modal -->
<div class="modal fade" id="recurConfirm" tabindex="-1" role="dialog" aria-labelledby="recurConfirm" aria-hidden="true">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-body">
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">
×
</button>
<p>Congratulations! Your recurring claim has been submitted and will be reviewed by our customer service team. We’ll contact you if we have any questions or concerns with your submission. If you have questions about your submission, please contact our customer service team at (800) 669-3539 or <a class="naviaLink" href="mailto:customerservice@naviabenefits.com">customerservice@naviabenefits.com</a>.</p>
</div>
<div class="modal-footer">
<input type="button" class="naviaBtn naviaBlue" data-dismiss="modal" value="okay" ng-click="recurOkay()">
</div>
</div>
<!-- /.modal-content -->
</div>
<!-- /.modal-dialog -->
</div>
<!-- /.modal -->
我的控制器函数(当用户保存数据然后进行重定向时触发此模式):
$scope.recurOkay = function() {
$('#recurConfirm').modal('hide');
$('body').removeClass('modal-open');
$('.modal-backdrop').remove();
$location.path('/#/pptHome');
};
而且我的路线很标准。
$location.path
方法仅接受 URL string
,该字符串不应包含 #
。基本上,此方法将在 URL
.
#
之后追加给定的 string
所以在你的情况下 $location.path('/#/pptHome');
执行后,它重定向到路由引擎无法识别的 URL http://localhost/#/#/pptHome
并重定向到回退 URL .
要解决此问题,请执行以下操作。
$location.path('/pptHome'); //will redirect to `/#/pptHome`