Get dynamic title support working

This commit is contained in:
Joseph Schorr 2015-02-27 17:22:47 -05:00
parent 7460541c89
commit 07a921c92c

View file

@ -4,15 +4,33 @@
angular.module('quay').factory('MetaService', ['$interpolate', 'Config', '$rootScope', '$interval',
function($interpolate, Config, $rootScope, $interval) {
var metaService = {};
var intervals = [];
var interpolate = function(page, expr, callback) {
$rootScope.$watch(page.scope, function() {
var previous = '';
var currentInterval = $interval(function() {
var inter = $interpolate(expr, true, null, true);
callback(inter(page.scope));
});
var result = inter(page.scope)
if (result != previous) {
$interval.cancel(currentInterval);
}
previous = result;
callback(result);
}, 500);
intervals.push(currentInterval);
};
var initial = function(value, default_value, callback) {
for (var i = 0; i < intervals.length; ++i) {
$interval.cancel(intervals[i]);
}
intervals = [];
if (!value) {
callback(default_value);
return;