-
Notifications
You must be signed in to change notification settings - Fork 4
/
app.js
34 lines (30 loc) · 1000 Bytes
/
app.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
var demoApp = angular.module('demoApp', ['ngRoute']);
demoApp.config(function($routeProvider, $locationProvider) {
$routeProvider.when('/timeline', {
templateUrl: 'partials/timeline.html',
controller: 'timelineCtrl'
}).when('/connect', {
templateUrl: 'partials/connect.html',
controller: 'connectCtrl'
}).otherwise({
redirectTo: '/connect'
});
$locationProvider.html5Mode(false);
});
demoApp.controller('connectCtrl', function connectCtrl($scope, $rootScope, $location) {
OAuth.initialize("~~~[[YOUR_OAUTH_IO_PUBLIC_KEY]]~~~");
$scope.connect = function() {
OAuth.popup("twitter", function(err, res) {
if (err) return alert(err);
$rootScope.twitter = res;
$location.path('/timeline');
$scope.$apply();
});
}
});
demoApp.controller('timelineCtrl', function timelineCtrl($scope, $rootScope) {
$rootScope.twitter.get('/1.1/statuses/home_timeline.json').done(function(data) {
$scope.tw_timeline = data;
$scope.$apply();
});
});