[英]How to redirect user to home page if user is authentic i.e ID or PASSWORD is correct in vue.js using VUEX STORE state?
[英]wants to redirect to home page in angular js if user type wrong path and show correct URL
如果我們強制編輯URL,則網頁將顯示具有不同URL的相同內容。 例如, http://www.example.com/#和http://www.example.com/#/abc提供相同的內容。 每次在URL中顯示正確的路徑時都想重定向主頁上的已編輯URL。
.state('system.confirmation', {
url: '/confirmation',
templateUrl: 'tpls/views/system/confirmation/confirmation.html',
controller: 'ConfirmationController',
controllerAs:'confirmationController',
}
$rootScope.$on('$routeChangeStart', function (event, next, last) {
console.log(event, next, last)// get all info, about current controller
$scope.someFunction();
});
您可以執行此操作,在更改任何路由之前,此函數將調用,您可以在此處檢查您正在談論的內容。
您正在尋找的是otherswise()
函數。 嘗試將其添加到您的config
函數中:
$urlRouterProvider.otherwise('/')
這樣可以確保將所有未捕獲的路由都重定向到您的基本URL。
嘗試這個
App.config(function($routeProvider) {
$routeProvider
// route for the home page
.when('/index', {
templateUrl : 'views/site/index.html',
controller : 'indexController'
})
// route for the about page
.when('/about', {
templateUrl : 'views/site/about.html',
controller : 'aboutController'
})
.when('/404', {
templateUrl : 'views/site/404.html',
controller : '404Controller'
})
.when('/signup', {
templateUrl : 'views/site/signup.html',
controller : 'signupController'
})
.when('/forgotPass', {
templateUrl : 'views/site/forgotPassword.html',
controller : 'forgotPassController'
})
.when('/login', {
templateUrl : 'views/site/login.html',
controller : 'loginController'
}).otherwise({
redirectTo: '/404'
});;
});
App.controller('404Controller',['$scope', function($scope) {
$scope.message = 'Page not found 404.';
}]);
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.