我正在尝试在ionic for mobile app中创建一个登录页面,在用户输入一些ID和密码之后,它将导航到另一个页面.我尝试使用state.go和location.path但它不起作用.这是代码:
angular.module('app.controllers', ['ionic','ui.router'])
.controller('loginCtrl', function($scope, $ionicPopup, $state) {
$scope.data ={};
$scope.submitData = function(){
if($scope.data.email && $scope.data.password){
var alertPopup = $ionicPopup.alert({
title: "Login Succesful",
template: "Welcome Back "
});
$state.go('stateHome');
}else{
var alertPopup = $ionicPopup.alert({
title: "Login Failed",
template: "Please check your credentials"
});
}
}
})
app.config(function($stateProvider, $urlRouterProvider) {
$stateProvider
.state('stateHome', {
url: '/Home',
views: {
'Home' :{
templateUrl : "templates/Home.html",
controller : 'HomeCtrl'
}
}
});
$urlRouterProvider.otherwise('/Setting');
})
Run Code Online (Sandbox Code Playgroud)
我的app.js包含:
angular.module('app', ['ionic', 'app.controllers', 'app.routes', 'app.services', 'app.directives'])
.run(function($ionicPlatform) …Run Code Online (Sandbox Code Playgroud)