在我的代碼location.path(「#/」)不工作我試了很多,但我不明白爲什麼它不工作。有一個簡單的邏輯,即成功註冊彈出窗口關閉後,通知欄插件將看到通知。location.path(「#/」)不工作
自從4小時後,我感到驚訝。
Signup
(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]);
}());
嘗試編輯散列代替路徑。 '$ location.hash('/')' –
@LuisMasuelli:謝謝你的回答。但它不起作用。它附加在url中,如下所示:http:// localhost:1000 /#/#%2F –
注意我使用'/'而不是'#/'。 –