2017-08-09 11 views
2

現在Ionic v1を使用しているプロジェクトで作業しています。私は、プロジェクトに複数のユーザータイプがあり、各ユーザータイプは時間に基づいて別のページにリダイレクトする必要があります。私はこれを達成することができません。ここに私のコードは次のとおりです。Ionic-V1の新しいページに移動

app.js:

.state('tab.login', { 
url: '/login', 
views: { 
    'tab-login': { 
    templateUrl: 'templates/tab-login.html', 
    controller: 'LoginCtrl' 
    } 
} 
}) 
.state('guest.home' , { 
    url: '/guesthome', 
    views: { 
    'guest-home': { 
     templateUrl: 'templates/guest-home.html', 
     controller: 'GuestCtrl' 
    } 
    } 
}) 

.state('agent.home' , { 
    url: '/agenthome', 
    views: { 
    'agent-home': { 
     templateUrl: 'templates/agent-home.html', 
     controller: 'AgentCtrl' 
    } 
    } 
}) 

controller.js:

.controller('LoginCtrl', function($scope, $state) { 
    $scope.userLogin = function(email, password) { 
    Backendless.UserService.login($scope.email, $scope.password, true) 
    .then($scope.userLoggedIn) 
    .catch ($scope.gotError) 
} 

$scope.userLoggedIn = function(user) { 
console.log("User has logged in"); 
if (user.user_type === "g") 
    $state.go('guest.home'); 
else 
    $state.go('agent.home'); 
} 

$scope.gotError = function(err) { 
console.log("error message - " + err.message); 
    console.log("error code - " + err.statusCode); 
} 

}) 

タブ-login.htmlと:

<ion-content class="padding" ng-controller="LoginCtrl"> 
<div class="list"> 
    <label class="item item-input item-floating-label"> 
    <span class="input-label">Email</span> 
    <input type="text" placeholder="Email" ng-model="email"> 
    </label> 
    <label class="item item-input item-floating-label"> 
    <span class="input-label">Password</span> 
    <input type="password" placeholder="Password" ng-model="password"> 
    </label> 
</div> 
<div class="text-center"> 
    <button class="button button-positive" ng-click="userLogin()"> 
    Login 
    </button> 
</div> 
</ion-content> 

私はエラーを取得していますerror message - Could not resolve 'guest.home' from state 'tab.login'私は間違って何をしていますか?

答えて

0

私は、あなたの状態名にドットを使用するという事実は、子どもを保持するための抽象的な状態を定義することなく、問題が発生すると考えています。

点( 'guesthome'多分?)を付けないでショットを付けたり、ルーティングを抽象的な状態に変更したりしてください。ここで

は例です:

 $stateProvider 
     .state('setup', { 
      url: '/setup', 
      abstract: true, 
      templateUrl: 'js/views/setupView.html', 
      controller: 'SetupController' 
     }) 
     .state('setup.bluetooth', { 
      url: '/bluetooth', 
      views: { 
       'setupContent': { 
        templateUrl: 'js/views/bluetoothSetupView.html', 
        controller: 'BluetoothSetupController' 
       } 
      } 
     }) 
     .state('setup.truck', { 
      url: '/truck', 
      views: { 
       'setupContent': { 
        templateUrl: 'js/views/truckSetupView.html', 
        controller: 'TruckSetupController' 
       } 
      } 
     }) 
関連する問題