0

Я играю с Ионное приложение с использованием Firebase backend. Моя проблема в том, что ng-click="loginUser(user)" не стреляет.Ионный ng-click not firing

Консоль показывает Подписано от Auth.$onAuthStateChanged() и ничего больше. Нажатие кнопки не отображает журнал Clicked!.

Это мой журнал Console.

Вот мой Войти страница:

<ion-view title="Login" hide-nav-bar="true" nav-transition="none" id="page8" style="background-color:#FFC900;"> 
<ion-content padding="true" class="manual-ios-statusbar-padding"> 
    <div id="login-container6"> 
     <div> 
      <img src="img/PqmLrUhgT9WL19CElH4P_skc_logo.png" width="85" height="auto" style="display: block; margin-left: auto; margin-right: auto;"> 
     </div> 
     <div class="spacer" style="height: 40px;"></div> 
     <form id="login-form5" class="list"> 
      <label class="item item-input" id="login-input5"> 
       <span class="input-label">Email</span> 
       <input type="email" placeholder="" ng-model="user.email"> 
      </label> 
      <label class="item item-input" id="login-input6"> 
       <span class="input-label">Password</span> 
       <input type="password" placeholder="" ng-model="user.password"> 
      </label> 
      <div class="spacer" style="height: 40px;"></div> 
      <button id="login-button3" class="button button-light button-block" ng-click="loginUser(user)">Log in</button> 
     </form> 
    </div> 
</ion-content> 

и вот Войти Контроллер:

.controller('loginCtrl', ['Firebase', 'Auth', '$stateParams', '$state', '$ionicModal', '$location', function (Firebase, Auth, $scope, $stateParams, $state, $ionicModal, $location) { 
    Auth.$onAuthStateChanged(function (authData, $location) { 
     if (authData) { 
      console.log("Signed in as :", authData.email); 
      $scope.loggedInUser = authData; 

      $state.go('tabsController.search') 
     } else { 
      console.log("Signed out"); 
      $scope.loggedInUser = null; 
     } 
    }); 

    // Log in 
    $scope.loginUser = function (user) { 
     console.log('Clicked!'); 
     if ($scope.isIncorrectValue(user.email) || $scope.isIncorrectValue(user.password)) { 
      $scope.error = "You filled out the form wrong..."; 
     } else { 
      Auth.$signInWithEmailAndPassword(user.email, user.password) 
       .then(function (authData) { 
        $scope.loggedInUser = authData; 
        console.log('AuthData =' + authData); 
       }).catch(function (error) { 
        $scope.error = "" + error; 
       }); 
     } 
    } 
}]) 

EDIT - Вот Routing:

angular.module('app.routes', []) 

.config(function ($stateProvider, $urlRouterProvider) { 

... // Other Pages 

.state('login', { 
    url: '/login', 
    templateUrl: 'templates/login.html', 
    controller: 'loginCtrl' 
}) 

... // Other Pages 

$urlRouterProvider.otherwise('/login') 

}); 
+1

Вы установили ng-контроллер? – Sajeetharan

+0

Вы назначили loginCtrl вашему виду? –

+0

У меня есть, я получаю консольный журнал Signed Out с loginCtrl. – dlanmaar

ответ

0

Моя проблема была в loginCtrl деклараций. У меня не было $scope и имел $state дважды, без ошибок.