0

初めて Ionic プロジェクトで AngularFire を使用しています。電子メールとパスワードを使用して Auth の firebase Web サイトのドキュメントの例に従いました。何らかの理由で、ng-model からの $scope 値が適切にバインドされていません。

angular.module('starter')
.controller('RegisterController', ['Auth', '$scope', function(Auth, $scope) {

  $scope.createUser = function() {
    $scope.message = null;
    $scope.error = null;

    Auth.$createUser({
      email: $scope.email,
      password: $scope.password
    })
    .then(function(userData) {
      $scope.message = "User created: ";
    })
    .catch(function(error) {
      $scope.error = error;
    });
  };

}]);

$scope.email$scope.password` をハードコードされた電子メールとパスワードに置き換えると、機能します。これは、電子メールとパスワードのモデル データを含むテンプレートです。

<ion-view view-title='Register A New Account' hide-back-button="false">
  <ion-content class='padding'>

    <div class="list list-inset">

      <label class='item item-input'>
       <span class='input-label'>Email</span>
        <input type="text" placeholder='example@email.com' ng-model="email">
      </label>

      <label class='item item-input'>
       <span class='input-label'>Password</span>
        <input type="password" placeholder='' ng-model='password'>
      </label>

      <label class='item item-input'>
       <span class='input-label'>Cell Phone</span>
        <input type="tel" placeholder='316-333-3333'>
      </label>

      <label class='item item-input'>
       <span class='input-label'>Date of Birth</span>
        <input type="date">
      </label>

      <label class='item item-input'>
        <span class='input-label'>City</span>
        <input type="number" placeholder='Wichita'>
      </label>

      <label class='item item-input'>
        <span class='input-label'>State</span>
        <input type="number" placeholder='Kansas'>
      </label>

      <label class='item item-input'>
        <span class='input-label'>Zipcode</span>
        <input type="number" placeholder='67208'>
      </label>



    </div>
    <ion-checkbox>
      I agree to terms and conditions
    </ion-checkbox>
    <button class='button button-block button-calm' ng-click='createUser()'>Login</button>

      <p ng-if='message'>Message: {{message}}</p>
      <p ng-if='error'>Error: {{error}}</p>
  </ion-content>
 </ion-view>

$scope 値の設定が間違っているのでしょうか、それとも createAuth メソッドに欠けているものがありますか?

4

1 に答える 1

2

他の誰かがこの問題に遭遇した場合、それは簡単な修正でした! $scope電子メールとパスワードの変数をユーザー オブジェクトにして、 を使用してそれらにアクセスする必要がありましたuser.email。この状態には、競合する子スコープがありました。

于 2015-07-23T13:57:30.763 に答える