Get dynamic title support working
This commit is contained in:
parent
7460541c89
commit
07a921c92c
1 changed files with 21 additions and 3 deletions
|
@ -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;
|
||||
|
|
Reference in a new issue