Reputation: 8690
For security reasons, Angular documentation clearly states to ...not use user input to generate templates dynamically
. However, I want to do just that. I would like to allow users to use input fields to generate CSS freely and use it to create their own templates, which they could then download. I know $sanitize
works to clean HTML, but I am not aware if there is anything that allows you to do this with CSS, that will protect the site from security vulnerabilities.
Is it possible?
Thanks in advance.
Upvotes: 0
Views: 190
Reputation: 576
You can preview user inputted templates with style tags. I've used $templateCache to load user html.
$scope.loadTemplate=function(){
var randomStringName=makeid();
$scope.templVar=randomStringName;
$templateCache.put(randomStringName,$scope.templ);
}
HTML
<div ng-include="templVar"></div>
http://plnkr.co/edit/8HP7HWwMvlXYiusE9TGH?p=preview
Upvotes: 1