Load angularjs dynamic templates in run() section
Change-Id: Ib0ae4618541a250941b4018cb0b9ffc966527a40
This commit is contained in:
parent
06d312a8c1
commit
b408d89815
@ -101,12 +101,9 @@
|
|||||||
return {
|
return {
|
||||||
restrict: 'E',
|
restrict: 'E',
|
||||||
scope: true,
|
scope: true,
|
||||||
link: function(scope, element, attrs) {
|
link: function(scope, element) {
|
||||||
$http.get(
|
var template = $templateCache.get(scope.spec.type);
|
||||||
'/static/mistral/js/angular-templates/fields/' + scope.spec.type + '.html',
|
element.replaceWith($compile(template)(scope));
|
||||||
{cache: $templateCache}).success(function(templateContent) {
|
|
||||||
element.replaceWith($compile(templateContent)(scope));
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
@ -13,6 +13,16 @@
|
|||||||
attrs[attrName] = $parse(attrs[attrName])();
|
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