2016-04-26 7 views
0

Hallo an alle Leser dieses! Ich habe ein Problem beim Ausführen der Funktion in meiner Strg.Controller-Funktion funktioniert nicht in Angular.js

Ich habe versucht, einige Warnungen zu machen, console.log und suche hier nach der Antwort, aber fand nicht genau dasselbe Problem, nur ähnlich. ich jedem dankbar sein werde ich dieses Problem)

HTML

// ctrls.js 
 

 
var gameApp = angular.module('gameApp'); 
 

 
var AuthorizationCtrl = gameApp.controller('AuthorizationCtrl', function($scope) { 
 
    $scope.email = email.value; 
 
    $scope.password = password.value; 
 
    $scope.signUp = function() { // this function isn't executed when I hope it to be 
 
     console.log($scope.email, $scope.password); 
 
     gameFactory.signUp(email, password).then(function() { 
 

 
     }); 
 
    }; 
 
}); 
 

 

 
// services.js 
 
function Factory(FBMSG, $firebaseArray, $firebaseAuth) { 
 
    var events = {}, 
 
     ref = new Firebase(FBMSG), 
 
     games = $firebaseArray(ref), 
 
     auth = $firebaseAuth(ref); 
 

 
    events.getAllGames = function() { 
 
     return games.$loaded(); 
 
    }; 
 

 

 
    events.signUp = function(email, password) { 
 
     return auth.createUser({ 
 
      email: email, 
 
      password: password 
 
     }); 
 
    }; 
 

 
    return events; 
 

 
}
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.23/angular.min.js"></script> 
 
<!-- ng-view --> 
 
<div ng-controller="AuthorizationCtrl" style="background-color: rgba(0, 0, 0, .5); width: 40%; margin:auto"> 
 
    <form> 
 
     <div class="form-group"> 
 
      <label for="email">Email address</label> 
 
      <input ng-model='email' type="email" class="form-control" id="email" placeholder="Email" required> 
 
     </div> 
 
     <div class="form-group"> 
 
      <label for="password">Password</label> 
 
      <input ng-model="password" type="password" class="form-control" id="password" placeholder="Password" required> 
 
     </div> 
 
     <a href="">Forgot your password?</a> 
 
     <div> 
 
      <button ng-click="SignUp()">SignUp</button> <!-- Problem!!! --> 
 
     </div> 
 
    </form> 
 
</div>

+0

Woher bekommen Sie 'email.value'? "$ scope.email = email.value'" – theblindprophet

+0

+0

hier anmelden statt Anmeldung. Sie haben Ihre Kappen falsch, checken Sie die ng-klick –

Antwort

0

Versuchen lösen helfen, Ihren HTML mit dieser Änderung in Ihrem ng klicken, Sie auf SignUp Bezug wurden statt Anmeldung

<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.23/angular.min.js"></script> 
<!-- ng-view --> 
<div ng-controller="AuthorizationCtrl" style="background-color: rgba(0, 0, 0, .5); width: 40%; margin:auto"> 
    <form> 
     <div class="form-group"> 
      <label for="email">Email address</label> 
      <input ng-model='email' type="email" class="form-control" id="email" placeholder="Email" required> 
     </div> 
     <div class="form-group"> 
      <label for="password">Password</label> 
      <input ng-model="password" type="password" class="form-control" id="password" placeholder="Password" required> 
     </div> 
     <a href="">Forgot your password?</a> 
     <div> 
      <button ng-click="signUp()">SignUp</button> <!-- signUp instead of SignUp!!! --> 
     </div> 
    </form> 
</div> 
+0

Vielen Dank! Es ist ein dummer Fehler. Schande über mich ((Ich sah für eine Stunde durch (( –

+0

Kein Problem! :) Bitte denken Sie daran, die Antwort zu akzeptieren. Wenn Sie ein anderes Problem haben, senden Sie mir eine direkte Nachricht und ich werde froh sein, Ihnen zu helfen! –