使用location.path函数后的Angular UI bootstrap模式重定向

时间:2016-02-21 19:08:39

标签: html angularjs twitter-bootstrap routing angular-ui-bootstrap

用户在此模式中单击“确定”后,应将其转到另一个页面。我在我的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">
                    &times;
                </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');
};

我的路线很标准。

1 个答案:

答案 0 :(得分:1)

$location.path方法仅接受网址string,该字符串中不应包含#。基本上,此方法会在string #之后的URL后添加$location.path('/#/pptHome');。{/ p>

因此,在您的情况http://localhost/#/#/pptHome执行后,它会重定向到路由引擎无法识别的网址$location.path('/pptHome'); //will redirect to `/#/pptHome` ,并重定向到后备网址。

要解决此问题,请执行以下操作。

colleges