Load angularjs dynamic templates in run() section
Change-Id: Ib0ae4618541a250941b4018cb0b9ffc966527a40
This commit is contained in:
parent
06d312a8c1
commit
b408d89815
@ -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));
|
||||
}
|
||||
}
|
||||
})
|
||||
|
@ -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);
|
||||
});
|
||||
})
|
||||
})
|
||||
|
||||
})();
|
Loading…
x
Reference in New Issue
Block a user