I am trying to create an ionic login page for a mobile application where, after a user enters an identifier and password, he will go to another page. I am trying to use state.go and location.path, but it does not work. Here is the code:
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'); })
My app.js contain:
angular.module('app', ['ionic', 'app.controllers', 'app.routes', 'app.services', 'app.directives']) .run(function($ionicPlatform) { $ionicPlatform.ready(function() {
any idea how to solve this?
source share