angularjs google sign in

我想在我的项目里面添加google calendar的功能,在google sign in的时候,我写了一个function是这样的:

    function onSignIn(googleUser) {
        googleUser.grantOfflineAccess({'redirect_uri': 'postmessage'}).then( function (authResult) {
            if (authResult['code']){
                var authcode=authResult['code'];
                console.log("code: " + authcode);
           
            }
        });
    }
    html: <div class="g-signin2" data-onsuccess="onSignIn"></div>

结果我发现,这个function写到header里面就可以生效,console log里面能够获得code的值,但是一旦把他放到angularjs的controller里面就不行了。有没有大神帮我解释一下这是为什么呢,问题出在哪里,要怎么解决呢?

阅读 2.1k
撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进