离子重定向
Ionic redirection
本文关键字:重定向 更新时间:2023-09-26
登录测试后,我尝试转到主页,但我遇到了问题。我使用了 $location.path("/templates/welcome.html");但它不起作用。
我在应用程序中的控制器.js是:
controller('SignInCtrl', function($scope, $state, $http) {
$scope.login = function(user) {
$http.get("http://localhost/app_dev.php/json/login/"+user.username+"/"+user.password)
.then(function(response){
console.log(response.data.status);
if(response.data.status === 200)
{
alert("redirect to main page");
$location.path("/templates/welcome.html");
}else if(response.data.status === 403){
alert("Login or password incorrect");
}else{
alert("User not found");
}
});
};
})
警报正在工作,但重定向不起作用。在控制台中,我有此错误:
ionic.bundle.js:25642 ReferenceError: $location is not defined
at app.js:37
像这样将$location注入控制器
controller('SignInCtrl', function($scope, $state, $http, $location) {
您尚未在控制器中注入$location服务。
我认为问题来自statProrovider。我的状态是:
.config(function($stateProvider, $urlRouterProvider) {
$stateProvider
.state('signin', {
url: '/sign-in',
templateUrl: 'templates/welcome.html',
controller: 'SignInCtrl'
})
})
在我的网页中:
<div ng-controller="SignInCtrl">
<form novalidate class="simple-form">
<div class="list list-inset">
<label class="item item-input">
<input type="text" placeholder="Username" ng-model="user.username">
</label>
<label class="item item-input">
<input type="password" placeholder="Password" ng-model="user.password">
</label>
</div>
<button class="button button-block button-calm" ng-click="login(user)">Login</button>
</form>
我刚刚开始使用Ionic,这就是为什么
相关文章:
- 通过javascript重定向html传递php变量
- JavaScript下拉菜单-点击按钮并根据所选值重定向到url
- 使用angular重定向到html页面
- 如何在chrome扩展中重定向到html页面
- 无法从jquery Mobile导航栏重定向到另一个页面
- ng视图外的链接重定向到ng视图内的页面
- 在phonegap应用程序内部重定向不起作用
- CORS-重定向到第二个GET正在接收的页面
- AJAX不会在文件上传后重定向到网页-POST方法
- 重定向时角度刷新浏览器
- 通过链接重定向不;我不在jstree中工作
- 根据select选项元素将表单重定向到不同的URL
- 通过JQuery重定向到另一个页面
- 重定向到“父窗口”
- 重定向iFrame中的父URL
- PHP-如何重定向到同一页面并更改DOM's
- chrome.tabs.update() 重定向到 'chrome-extension://invalid/'
- 我们如何在不更改url的情况下使用锚点点击从一个页面重定向到另一个页面
- 使用AngularJS中的UI路由器将状态重定向到默认子状态
- 刷新后重定向到其他URL