登录成功后如何重定向到主页
我正在使用UI-router,下面是我的ui-router代码。
var mymodule2 = angular.module('module2', []);
mymodule2.controller('controller2', function ($scope) {
$scope.loginFunction = function () {
alert("Login");
if ($scope.username == 'abcd' && $scope.password == 'hello123') {
console.log('Login sucessfull');
***// Redirect to Home Page.***
}
}
});
我有一个按钮元素,调用ng-click ='登录功能'用于验证用户名和密码。一旦凭据有效,我想将页面重定向到" Home.html"
如何在成功登录以下功能后调用ui-route?
struct gcrInfoStruct {
var folderView = " "
var actionType = " "
var isProtocolReview = " "
var folder: [folderDetail] = []
}
答案 0 :(得分:0)
您可以像这样使用$state.go("home");
,其中" home"是你想去的州名:
var mymodule2 = angular.module('module2', []);
mymodule2.controller('controller2', function ($scope, $state) {
$scope.loginFunction = function () {
alert("Login");
if ($scope.username == 'abcd' && $scope.password == 'hello123') {
console.log('Login sucessfull');
$state.go("home");
}
}
});
答案 1 :(得分:0)
使用`$ state.go(“home”);
var mymodule2 = angular.module('module2', []);
mymodule2.controller('controller2', function ($scope) {
$scope.loginFunction = function () {
alert("Login");
if ($scope.username == 'abcd' && $scope.password == 'hello123') {
console.log('Login sucessfull');
// add $state.go here
$state.go("home);
}
}
});