forked from launchscout/angular-googleapi
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcontrollers.js
41 lines (35 loc) · 1.48 KB
/
controllers.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
angular.module('demo', ["googleApi"])
.config(function(googleLoginProvider) {
googleLoginProvider.configure({
clientId: '740768586841-dv4c8jpq3l1e59oqipm4plmjkjgbvp5r.apps.googleusercontent.com',
scopes: [
"https://www.googleapis.com/auth/userinfo.email",
"https://www.googleapis.com/auth/calendar",
"https://www.googleapis.com/auth/plus.login"]
});
})
.controller( 'DemoCtrl',
['$scope', 'googleLogin', 'googleCalendar', 'googlePlus', 'googleDrive',
function ($scope, googleLogin, googleCalendar, googlePlus, googleDrive) {
$scope.login = function () {
googleLogin.login();
};
$scope.$on("googlePlus:loaded", function() {
googlePlus.getCurrentUser().then(function(user) {
$scope.currentUser = user;
});
});
$scope.currentUser = googleLogin.currentUser;
$scope.loadEvents = function() {
this.calendarItems = googleCalendar.listEvents({calendarId: this.selectedCalendar.id});
};
$scope.loadCalendars = function() {
$scope.calendars = googleCalendar.listCalendars();
};
$scope.$on("googleDrive:loaded", function() {
googleDrive.listFiles().then(function(files) {
$scope.files = files.items;
});
})
}]
);