Angularjs Firebase createAuth凭据不是';t使用ng模型范围变量
我第一次在爱奥尼亚项目中使用AngularFire。我在firebase网站上的文档中使用电子邮件和密码进行了验证。由于某些原因,ng模型中的$scope值没有正确绑定Angularjs Firebase createAuth凭据不是';t使用ng模型范围变量,angularjs,ionic-framework,angularfire,firebase-authentication,Angularjs,Ionic Framework,Angularfire,Firebase Authentication,我第一次在爱奥尼亚项目中使用AngularFire。我在firebase网站上的文档中使用电子邮件和密码进行了验证。由于某些原因,ng模型中的$scope值没有正确绑定 angular.module('starter') .controller('RegisterController', ['Auth', '$scope', function(Auth, $scope) { $scope.createUser = function() { $scope.message = null
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>
电子邮件
密码
手机
出生日期
城市
陈述
Zipcode
我同意条款和条件
登录
消息:{{message}
error:{{error}
是我的$scope值设置错误,还是我缺少createAuth方法?如果其他人遇到这个问题,这是一个简单的解决方案!我只需将电子邮件和密码的
$scope
变量设置到用户对象中,就可以使用user.email
访问它们。此状态具有冲突的子作用域