/**
* Service which helps set the contents of the <meta> tags (and the <title> of a page).
*/
angular.module('quay').factory('MetaService', ['$interpolate', '$timeout', function($interpolate, $timeout) {
var metaService = {};
var interpolate = function(page, expr) {
if (!expr) {
return null;
}
var inter = $interpolate(expr, true, null, true);
if (!inter) {
return expr.toString();
return inter(page.scope);
};
metaService.getTitle = function(page) {
if (!page || !page.$$route) {
var route = page.$$route;
return interpolate(page, route && route.title);
metaService.getDescription = function(page) {
return new Promise(function(resolve, reject) {
resolve(null);
} else {
// Timeout needed because page.scope is undefined
$timeout(function() {
resolve(interpolate(page, page.$$route.description));
}, 10);
});
return metaService;
}]);