Load angularjs dynamic templates in run() section

Change-Id: Ib0ae4618541a250941b4018cb0b9ffc966527a40
This commit is contained in:
Timur Sufiev 2015-01-09 04:59:07 -08:00
parent 06d312a8c1
commit b408d89815
2 changed files with 14 additions and 7 deletions

View File

@ -101,12 +101,9 @@
return {
restrict: 'E',
scope: true,
link: function(scope, element, attrs) {
$http.get(
'/static/mistral/js/angular-templates/fields/' + scope.spec.type + '.html',
{cache: $templateCache}).success(function(templateContent) {
element.replaceWith($compile(templateContent)(scope));
});
link: function(scope, element) {
var template = $templateCache.get(scope.spec.type);
element.replaceWith($compile(template)(scope));
}
}
})

View File

@ -13,6 +13,16 @@
attrs[attrName] = $parse(attrs[attrName])();
}
}
});
})
.run(function($http, $templateCache) {
var fields = ['dictionary', 'frozendict', 'list', 'string', 'varlist'];
fields.forEach(function(field) {
var base = '/static/mistral/js/angular-templates/fields/';
$http.get(base + field + '.html').success(function(templateContent) {
$templateCache.put(field, templateContent);
});
})
})
})();