location.path("#/")不起作用

时间:2016-03-30 15:34:13

标签: angularjs mean

在我的代码location.path("#/")不起作用我已经尝试了很多,但我不明白它为什么不起作用。有一个简单的逻辑,即成功注册弹出窗口关闭后,通知栏插件会看到通知。

我从4个小时开始接受这个。

  

注册

    (function () {
        'use strict'
        /*
         * Signup Controller
         * @param {$scope} Object
         * @return
         */
        function SignupCtrl($scope, $location, $window, $timeout, UserService, notifications) {
            //$scope.captchaError=false;
            //$scope.passwordPattern = '((?=.*\d)(?=.*[a-z])(?=.*[A-Z])(?=.*[@#$%]).{8,})';
            $scope.doRegistration = function () {
                console.log("form validation status:" + $scope.frmSignup.$valid);
                if (true === $scope.frmSignup.$valid) {
                    console.log("validation successfully executed");
                    UserService
                            .register($scope.user)
                            .error(function () {
                                angular.element('#btnCancelSignup').triggerHandler('click');
                                notifications.showError({
                                    message: 'Ooops! there is error occured, please try again.',
                                    hideDelay: 1500, //miliseconds
                                    hide: true // boolean
                                });
                                $location.path("#/");
                            })
                            .then(function (res) {
                                if (res.data.status === 1) {
                                    console.log("success in registration");
                                    angular.element('#btnCancelSignup').trigger('click');
                                    notifications.showSuccess({
                                        message: 'Please check your email to complete registration.',
                                        hideDelay: 1500, //miliseconds
                                        hide: true // boolean
                                    });
                                    $location.path("#/");
                                    if(!$scope.$$phase) $scope.$apply();

                                }
                                Recaptcha.reload();
                            });
                }
            }
        }

        angular
                .module('AppWhizbite')
                .controller('SignupCtrl', ['$scope', '$location', '$window', '$timeout', 'UserService', 'notifications', SignupCtrl]);
    }());

2 个答案:

答案 0 :(得分:0)

尝试以下

$("#inventory_table .itemcode").on("focus", function(){
alert( "On focus for table inventory called." );

alert($(this).text());
});

这是您可能阅读的另一篇文章,以便更好地理解Angular $location.path not working

答案 1 :(得分:0)

来自$location doc

  

更改浏览器URL时,不会导致整页重新加载。要在更改URL后重新加载页面,请使用较低级别的API $ window.location.href。

所以,试试:

func Pic(dx, dy int) [][]uint8 {
    matrix := make([][]uint8, dx)

    for i := 0; i < dx; i++ {
        matrix[i] = make([]uint8, dy)
        for j := 0; j < dy; j++ {
            matrix[i][j] = Z(i, j)
        }
    }
    return matrix
}