【发布时间】:2017-10-23 05:46:12
【问题描述】:
我的控制器有问题
.factory('Auth', function($firebaseAuth){
var auth = $firebaseAuth();
return auth;
})
.controller('authCtrl', function() {
var authCtrl = this;
authCtrl.user = {
email: '',
password: ''
};
console.log('hoi1');
authCtrl.login = function (){
console.log('hoi2');
};
});
-
<div id="loginModal" class="modal" ng-controller="authCtrl">
<div class="modal-background"></div>
<div class="modal-content">
<div class="modal-body">
<form ng-submit="authCtrl.login()">
<h1>Login</h1>
<p id="loginError"> </p>
<input type="email" name="loginEmail" value="" placeholder="email" class="input" ng-model="authCtrl.user.email">
<br>
<input type="password" name="loginPassword" value="" placeholder="******" class="input" ng-model="password" ng-model="authCtrl.user.password">
<br>
<input type="submit" value="Login">
</form>
</div>
</div>
控制器一直在我体内,但是我在控制台看到hoi1,但是当我提交表单时,却没有得到hoi2
怎么了?
真诚地, 尤尔
【问题讨论】:
-
试试
ng-controller="authCtrl as authCtrl"。 @HARI 的答案有效,但不是最佳实践。
标签: angularjs firebase firebase-authentication angularfire