1

我的 index.html 中有标准的 LinkedIn JSAPI 脚本:

<script type="text/javascript" src="http://platform.linkedin.com/in.js"></script>

我正在使用 Angular.js 并在我的登录页面中有此代码:

<button class="btn btn-primary" ng-click="FBlogin()">Connect with Facebook</button> 
<script type="in/Login" data-onAuth="getLinkedInProfile"></script>
<script type="text/javascript">
    // upon getting in.js above, apply to register window scope
    function getLinkedInProfile() {
        IN.API.Profile("me").fields(["id", "firstName", "lastName", "email-address", "picture-urls::(original)", "industry", "languages", "educations", "three-current-positions", "three-past-positions"])
            .result(function(me) {
              angular.element(document.getElementById('login_window')).scope().linkedInRegistration(me) // calls scope function
            })
            .error(function(error) {
              console.log('>> error on LinkedInLoad', error)
            })
    }
</script>

在某些随机的机会中,按钮根本不会出现。我有点注意到,如果我删除了所有 fields() 选项,那么按钮将可靠地显示出来,但如果这是原因,我不会。有什么建议么?

4

2 回答 2

0

我不是角度专家,但我可以告诉你,一旦用户第一次进行身份验证,只要他登录到 LinkedIn.com,他就会自动登录到你的网站并且按钮消失。

这只发生在 JavaScript API 中,我相信这就是您身边发生的事情。

于 2015-01-22T14:16:42.133 回答
0

我今天注意到,当状态改变时,linkedIn 登录按钮消失了。如果按钮处于状态 A 并且状态更改为 B 然后又回到 A,则不再显示该按钮。我通过使用指令来放置按钮而不是将其硬编码到视图中来解决它。我使用的解决方案是在 stackoverflow 上对类似问题的回答: LinkedIn 共享按钮仅出现在 AngularJS 应用程序的初始加载时

希望这可以帮助其他人来:-)

于 2016-05-09T18:08:01.530 回答