bower install angular-tabletop --save
angular
.module('myApp', [
'times.tabletop'
])
...
.config(function(TabletopProvider) {
TabletopProvider.setTabletopOptions({
key: '', // Your key here.
simpleSheet: true // Any Tabletop option except 'callback' works.
});
});
Optionally, you can resolve Tabletop before the controller loads using ui-router
:
angular
.module('myApp', [
'times.tabletop'
'ui.router'
])
.config(function($stateProvider, $urlRouterProvider, TabletopProvider) {
// Tabletop setup...
TabletopProvider.setTabletopOptions({
key: 'https://docs.google.com/spreadsheets/d/1RVnUq3oMwt9aLROzgDJDbPlacjzWkOnx8pzzvX4Lcw4/pubhtml',
});
$urlRouterProvider.otherwise('/');
// Now set up the states
$stateProvider
.state('map', {
url: '/',
templateUrl: 'partials/map.html',
resolve: {
tabletopData: 'Tabletop'
},
controller: function($scope, tabletopData) {
$scope.data = tabletopData; // This will be a resolved promise!
}
});
});
If you use angular-translate, you can use Tabletop to store all your app's translations. This can also be used to give non-developers the ability to easily change an AngularJS app's microcopy — no more doing new builds for simple text tweaks!
i18n en_US
. This assumes American English; if, for instance, you wanted Canadian French, you would put the language identifier fr_CA
. See this helpful table.SOME_STRING_HERE
in your code as the "key" and "This is some text" as the "value".Tabletop_i18nLoader.js
in your app.When configuring your app, provide angular-translate
with tabletopi18nLoader
as the loader as such:
angular.module('yourApp', [
'times.tabletop',
'pascalprecht.translate'
])
.config(function(TabletopProvider, $translateProvider) {
// Tabletop setup...
TabletopProvider.setTabletopOptions({
key: 'your-key-here',
simpleSheet: false
});
// Translation setup (defaults used below)...
$translateProvider.useLoader('tabletopi18nLoader',
{
lang: 'en_US', // The language identifier used to name your sheet.
prefix: 'i18n ', // This is the bit before the lang identifier. Note the space.
keyKey: 'key', // This is the name of your "key" column.
valueKey: 'value' // This is the name of your "value" column.
}
);
});
tabletopi18nLoader
for easy translations.