Angularjs 页面未在JS中重定向
我有一个按钮,我在其中注册了一个点击事件。现在根据我的要求,我想我的当前页面路由到下一页使用角JS路由。我试图添加路由代码在我的点击事件,但它没有发生。这是我的JS代码Angularjs 页面未在JS中重定向,angularjs,Angularjs,我有一个按钮,我在其中注册了一个点击事件。现在根据我的要求,我想我的当前页面路由到下一页使用角JS路由。我试图添加路由代码在我的点击事件,但它没有发生。这是我的JS代码 var app = angular.module('LoginApp', ['ngRoute']); app.config(function ($routeProvider) { app.controller('LoginformController', function ($scope) { $scop
var app = angular.module('LoginApp', ['ngRoute']);
app.config(function ($routeProvider) {
app.controller('LoginformController', function ($scope) {
$scope.LoginCheck=function () {
alert("Trying to login !");
}
});
现在,在发出警报后,我希望此页面导航到“Home.html”。请帮助我如何在警报消息后路由到“Home.html”。谢谢
我正在尝试添加以下代码,但页面无法导航
app.config(function ($routeProvider) {
app.controller('LoginformController', function ($scope,$location) {
$scope.LoginCheck=function () {
alert("Trying to login !");
$location.path('/Home.html');
}
$scope.PasswordRecovery = function () {
alert("Clicked 2");
}
});
});
试试这个
var app = angular.module('LoginApp', ['ngRoute']);
app.config(function ($routeProvider) {
app.controller('LoginformController', ['$scope', '$location', function ($scope, $location) {
$scope.LoginCheck=function () {
alert("Trying to login !");
$location.path('path where to redirect');
}
}]);
$location.path同时是getter和setter
当没有参数ie$location.path()时,它将获得代码>
当使用参数ie$location.path('path to redirect')时,它将被设置
var app = angular.module('LoginApp', ['ngRoute']);
app.config(function ($routeProvider) {
app.controller('LoginformController', ['$scope', '$location', function ($scope, $location) {
$scope.LoginCheck=function () {
alert("Trying to login !");
$location.path('path where to redirect');
}
}]);
$location.path同时是getter和setter
当没有参数ie$location.path()时,它将获得代码>
当使用参数ie$location.path('path to redirect')时,它将被设置
var app = angular.module('LoginApp', ['ngRoute']);
app.config(function ($routeProvider) {
app.controller('LoginformController', ['$scope', '$location', function ($scope, $location) {
$scope.LoginCheck=function () {
alert("Trying to login !");
$location.path('path where to redirect');
}
}]);
$location.path同时是getter和setter
当没有参数ie$location.path()时,它将获得代码>
当使用参数ie$location.path('path to redirect')时,它将被设置
var app = angular.module('LoginApp', ['ngRoute']);
app.config(function ($routeProvider) {
app.controller('LoginformController', ['$scope', '$location', function ($scope, $location) {
$scope.LoginCheck=function () {
alert("Trying to login !");
$location.path('path where to redirect');
}
}]);
$location.path同时是getter和setter
当没有参数ie$location.path()时,它将获得代码>
当使用参数ie$location.path('path to redirect')时,它将被设置。
请尝试以下操作:
var app = angular.module('LoginApp', ['ngRoute']);
app.config(['$routeProvider',function ($routeProvider) {
$routeProvider
.when('/Login', {
templateUrl: 'LoginView.html',
controller: 'LoginController'
})
}])
app.controller('LoginformController', function($scope,$location) {
$scope.LoginCheck = function(){
alert("Trying to login !");
$location.path('/Login');
}
});
试试这个:
var app = angular.module('LoginApp', ['ngRoute']);
app.config(['$routeProvider',function ($routeProvider) {
$routeProvider
.when('/Login', {
templateUrl: 'LoginView.html',
controller: 'LoginController'
})
}])
app.controller('LoginformController', function($scope,$location) {
$scope.LoginCheck = function(){
alert("Trying to login !");
$location.path('/Login');
}
});
试试这个:
var app = angular.module('LoginApp', ['ngRoute']);
app.config(['$routeProvider',function ($routeProvider) {
$routeProvider
.when('/Login', {
templateUrl: 'LoginView.html',
controller: 'LoginController'
})
}])
app.controller('LoginformController', function($scope,$location) {
$scope.LoginCheck = function(){
alert("Trying to login !");
$location.path('/Login');
}
});
试试这个:
var app = angular.module('LoginApp', ['ngRoute']);
app.config(['$routeProvider',function ($routeProvider) {
$routeProvider
.when('/Login', {
templateUrl: 'LoginView.html',
controller: 'LoginController'
})
}])
app.controller('LoginformController', function($scope,$location) {
$scope.LoginCheck = function(){
alert("Trying to login !");
$location.path('/Login');
}
});
在添加`$location.path('/Home.html')时,获取和错误为ReferenceError:$location未定义
`显然,把$location
作为一项服务放在你的功能中我已经根据你的建议用我的试用代码更新了我的帖子,但它不起作用。请看一看。删除Home.html之前的斜杠写为$location.path('Home.html');您是否正在使用htm5Mode(true)?在添加“$location.path”('/Home.html')时,获取并错误为ReferenceError:$location未定义“/code>”`显然,把$location
作为一项服务放在你的功能中我已经根据你的建议用我的试用代码更新了我的帖子,但它不起作用。请看一看。删除Home.html之前的斜杠写为$location.path('Home.html');您是否正在使用htm5Mode(true)?在添加“$location.path”('/Home.html')时,获取并错误为ReferenceError:$location未定义“/code>”`显然,把$location
作为一项服务放在你的功能中我已经根据你的建议用我的试用代码更新了我的帖子,但它不起作用。请看一看。删除Home.html之前的斜杠写为$location.path('Home.html');您是否正在使用htm5Mode(true)?在添加“$location.path”('/Home.html')时,获取并错误为ReferenceError:$location未定义“/code>”`显然,把$location
作为一项服务放在你的功能中我已经根据你的建议用我的试用代码更新了我的帖子,但它不起作用。请看一看。删除Home.html之前的斜杠写为$location.path('Home.html');你使用的是htm5Mode(true)吗?使用状态提供程序可能比使用路由提供程序要好,请查看@JoeLloyd。请查看我发布的更新代码。错误是什么。请告诉我可能需要
,所以更改此行$location.path('./Home.html')代码>@JoeLloyd已尝试但未工作。我收到一个错误作为错误:[ng:areq]操作%2C%20在控制台中未定义%20“它引发了什么错误?使用状态提供程序可能比使用路由提供程序要好,请查看@JoeLloyd。请查看我发布的更新代码。错误是什么。请告诉我可能需要
,因此更改此行$location.path('./Home.html'));代码>@JoeLloyd已尝试但未工作。我收到一个错误作为错误:[ng:areq]操作%2C%20在控制台中未定义%20“它引发了什么错误?使用状态提供程序可能比使用路由提供程序要好,请查看@JoeLloyd。请查看我发布的更新代码。错误是什么。请告诉我可能需要
,因此更改此行$location.path('./Home.html'));代码>@JoeLloyd已尝试但未工作。我收到一个错误作为错误:[ng:areq]操作%2C%20在控制台中未定义%20“它引发了什么错误?使用状态提供程序可能比使用路由提供程序要好,请查看@JoeLloyd。请查看我发布的更新代码。错误是什么。请告诉我可能需要
,因此更改此行$location.path('./Home.html'));代码>@JoeLloyd已尝试但未工作。我收到一个错误作为错误:[ng:areq]nction%2C%20在控制台中未定义%20`它抛出了什么错误?