【发布时间】:2023-03-24 17:16:01
【问题描述】:
我使用parse 和angularjs 来验证用户。这是login 函数。
$scope.doLogin = ->
Parse.User.logIn $scope.currentUser.username, $scope.currentUser.password,
success: (user) ->
console.log user
$scope.currentUser = user
error: (user, error) ->
console.log error
这是表单(在同一页面、导航栏下拉菜单和页面内容中使用了两次):
%form{"ng-submit" => "doLogin()"}
%input{"ng-model" => "currentUser.username", type: "text"}
%input{"ng-model" => "currentUser.password", type: "password"}
%button.btn.btn-block
%center Connexion
问题是每当提交表单时,我都可以在控制台中看到user 对象,但$scope.currentUser 并不总是得到更新。有时我必须连续提交 3 或 4 次表单才能更新。
我做错了什么?谢谢。
【问题讨论】:
-
不就是因为异步吗?
-
@user1737909 我知道但是如何解决这个问题?
-
你可以在promise对象上调用
.then
标签: javascript data-binding angularjs coffeescript parse-platform