Last active
May 23, 2016 11:16
-
-
Save jeshan/77f4b06e1be50fdd0db6b719d6ab7aff to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html ng-app='angularApp'> | |
<head> | |
<script src="https://code.jquery.com/jquery.min.js"></script> | |
<link href="https://netdna.bootstrapcdn.com/twitter-bootstrap/2.3.2/css/bootstrap-combined.min.css" rel="stylesheet" type="text/css" /> | |
<script src="https://netdna.bootstrapcdn.com/twitter-bootstrap/2.3.2/js/bootstrap.min.js"></script> | |
<meta name="description" content="angular-intro-11; internationalisation"> | |
<script src="//ajax.googleapis.com/ajax/libs/angularjs/1.3.2/angular.min.js"></script> | |
<script src="//code.angularjs.org/1.3.2/i18n/angular-locale_en-gb.js"></script> | |
<script src="script.js"> | |
</script> | |
<meta charset="utf-8"> | |
</head> | |
<body ng-controller='MainController'> | |
<table class='table table-striped'> | |
<tr> | |
<th>Speaker</th> | |
<th>Title</th> | |
<th>Time</th> | |
</tr> | |
<tbody> | |
<tr ng-repeat='session in sessions'> | |
<td ng-bind='session.speaker'></td> | |
<td ng-bind='session.title'></td> | |
<td ng-bind='session.time'></td> | |
</tr> | |
</tbody> | |
</table> | |
</body> | |
</html> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var app = angular.module('angularApp', [ ]); | |
app.controller('MainController', function(sessionService, $scope) { | |
sessionService.getList().then(function(response) { | |
console.log(response); | |
$scope.sessions = response; | |
}); | |
}); | |
app.factory('sessionService', function ($log, $http, $q, $timeout) { | |
return { | |
getList: function (id) { | |
// https://spreadsheets.google.com/feeds/worksheets/1eGVUyO9U_JqSMqF2ZQSCyzRMAxOlplFGJ6L2uwfnoDw/public/full | |
var key = "1eGVUyO9U_JqSMqF2ZQSCyzRMAxOlplFGJ6L2uwfnoDw"; | |
var sheet = "od6"; | |
switch (id) { | |
case 2: | |
sheet = "otxbfq6"; | |
break; | |
case 3: | |
sheet = "o3xkksm"; | |
break; | |
case 4: | |
sheet = "ol3w1dm"; | |
break; | |
case 5: | |
sheet = "o9ypq48"; | |
break; | |
} | |
var feedUrl = "https://spreadsheets.google.com/feeds/list/" + key + "/" + sheet + "/public/values?alt=json&callback=JSON_CALLBACK"; | |
return $q(function (resolve, reject) { | |
$timeout(function () { | |
var feedList = []; | |
$http.jsonp(feedUrl) | |
.then(function (data) { | |
angular.forEach(data.data.feed.entry, function (entryX) { | |
entryX = { | |
abstract: entryX.gsx$abstract.$t, | |
language: entryX.gsx$language.$t, | |
level: entryX.gsx$level.$t, | |
room: entryX.gsx$room ? entryX.gsx$room.$t : undefined, | |
speaker: entryX.gsx$speaker.$t, | |
time: entryX.gsx$time.$t, | |
title: entryX.gsx$title.$t, | |
updated: entryX.updated.$t | |
}; | |
feedList.push(entryX); | |
}); | |
resolve(feedList); | |
}, function (error) { | |
console.log('error getting data'); | |
}); | |
}); | |
}); | |
} | |
}; | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment