Angular Js and google api client.js (gapi)

后端 未结 8 1513
不思量自难忘°
不思量自难忘° 2020-11-29 00:46

It took me one day to make it works so I think my experience may be useful from someone. And maybe some others will find improvement.

So I start angularJS two days a

8条回答
  •  情歌与酒
    2020-11-29 01:25

    Although pretty much on progress maybe also worth to mention angular-googleapi, which wraps nicely some Google Calendar and Google Plus API calls and easy extendable.

    You'd need to add this bit to your controller when checking for authorisation:

    $scope.authenticated = false;
    
    $scope.$on("google:authenticated", function(){
       $scope.authenticated = true;
       $scope.$on('googleCalendar:loaded', function(){
           # work your magic here
           # $scope.calendars = googleCalendar.listCalendars();
           # $scope.$apply();
       });
    });
    
    function checkAuth() {
       setTimeout(function(){
           gapi.auth === undefined ? checkAuth() : googleLogin.checkAuth();
       }, 20);
    }
    
    checkAuth();
    

提交回复
热议问题