【问题标题】:Ionic App I've been having this issue for quite some time now is it a permissions issue?Ionic App 我遇到这个问题已经有一段时间了,是权限问题吗?
【发布时间】:2016-07-06 12:26:11
【问题描述】:

登录应用程序后,我想将配置文件(前端)数据(用户名和电子邮件)绑定到前端。但这不起作用。我在这里做错了什么吗?

$scope.login = function() {
  fbref.$authWithPassword({
    email: $scope.email,
    password: $scope.password
  }).then(function(authData) {
    $scope.userprofile = authData;
    $state.go('tabsController.pendingTasks');
  })
}
<div ng-controller="loginCtrl" class="card" ng-show="user">
  <div class="item item-divider">Username: {{userprofile.email}}&nbsp;&nbsp;&nbsp;
  </div>
  <div class="item item-text-wrap">
    {{userprofile.password.email}}
  </div>
</div>

【问题讨论】:

  • $authWithPassword 不应该是 authWithPassword 吗?我不是火力基地的人,但快速搜索发现了这个firebase.com/docs/web/api/firebase/authwithpassword.html
  • 我使用了 $authWithPassword 并且它有效。我只是无法在前端绑定。
  • 所以 $scope.userprofile 被正确分配了吗?如果是这样,您将需要与我们分享更多代码,最好是 plunker 或 jsfiddle。
  • 它是一个离子应用程序,它会在 jsfiddle 上运行吗?

标签: angularjs ionic-framework firebase


【解决方案1】:

根据文档,成功回调返回一个包含字段 uid、provider、auth 和 expires 的对象。在该回调中放置一个断点或将其记录到控制台。

https://www.firebase.com/docs/web/api/firebase/authwithpassword.html

console.log('authData', authData);

【讨论】:

  • 好吧,这是有道理的,但我怎样才能在数据过期之前在前端传递数据。所以我可以绑定它
  • 检查authData.auth的值
  • 我已经用 pouchdb 尝试过这个东西,它仍然可以正常工作,我认为问题可能出在路由上。执行 $state.go() 时;不知何故,数据丢失了。
  • 我怀疑 pouchdb 与它有什么关系。确保在回调中调用 $scope.$apply() 以触发摘要循环。
【解决方案2】:

使用 cacheProfile 效果很好。例如 $scope.cachedProfile = authData.google.cachedUserProfile; $scope.cachedProfile.password = $scope.cachedProfile.uid; $scope.profileImage = authData.google.profileImageURL;

【讨论】:

    猜你喜欢
    • 2022-01-20
    • 2019-03-26
    • 1970-01-01
    • 1970-01-01
    • 2021-11-02
    • 2022-07-16
    • 2018-12-22
    • 2019-10-07
    • 1970-01-01
    相关资源
    最近更新 更多