2015-09-03 4 views
0

Я хочу открыть другое модальное окно, когда нужно щелкнуть ссылку в первом модальном окне. При нажатии на Забытый пароль я хочу открыть другое модальное окно forgetpassword.html Я попытался решить, используя модальный JS. Вот код:Почему я не могу открыть другое модальное окно в Ionic

ИОННОГО HTML

<ion-modal-view> 
    <ion-header-bar> 
    <h1 class="title">Login</h1> 
    <div class="buttons"> 
     <button class="button button-clear" ng-click="closeLogin()"> <i class="icon ion-close-round"></i></button> 
    </div> 
    </ion-header-bar> 
    <ion-content> 
    <form ng-submit="doLogin()"> 
     <div class="list"> 
     <label class="item item-input"> 
      <span class="input-label">Username</span> 
      <input type="text" ng-model="loginData.username"> 
     </label> 
     <label class="item item-input"> 
      <span class="input-label">Password</span> 
      <input type="password" ng-model="loginData.password"> 
     </label> 
     <label class="item borderbottomnone"> 
      <button class="button button-block button-positive" type="submit">Log in</button> 
      <span class="loginforgotpassword"><a ng-controller='MainCtrl' ng-click="openModal()">>Forgot password</a></span> 
      <span class="loginregister"><a href="#">REGISTER</a></span> 
     </label> 
     </div> 
    </form> 
    </ion-content> 
</ion-modal-view> 

JS

app.controller('MainCtrl', function($scope, $ionicModal) { 
    $scope.contact = { 
    name: 'Mittens Cat', 
    info: 'Tap anywhere on the card to open the modal' 
    } 

    $ionicModal.fromTemplateUrl('forgotpassword.html', { 
    scope: $scope, 
    animation: 'slide-in-up' 
    }).then(function(modal) { 
    $scope.modal = modal 
    }) 

    $scope.openModal = function() { 
    $scope.modal.show() 
    } 

    $scope.closeModal = function() { 
    $scope.modal.hide(); 
    }; 

    $scope.$on('$destroy', function() { 
    $scope.modal.remove(); 
    }); 
}) 
+0

ваш «забытый пароль» модальный открывается впервые? но не второй раз? –

ответ

1

Скорее всего, что ваш объект modal является перекрываться родительским модальным объектом, поэтому изменить модальное имя объекта, как это

$ionicModal.fromTemplateUrl('forgotpassword.html', { 
    scope: $scope, 
    animation: 'slide-in-up' 
    }).then(function(modal) { 
    $scope.forgotPasswordModal = modal 
    }) 

    $scope.openModal = function() { 
    $scope.forgotPasswordModal.show() 
    } 

    $scope.closeModal = function() { 
    $scope.forgotPasswordModal.hide(); 
    };