Reputation: 65
My template.html contains lots of html and inline css using all mixed together. This is because ultimately it is intended for email.
Angular does not like this and gives me this warning:
Ignoring , as this element is unsafe to bind in a template without proper sanitization. This may become an error in future versions of AngularDart. See https://webdev.dartlang.org/angular/guide/security for details.
I see on the documentation it recommends using "bypassSecurityTrustHtml" or similar, however that involves something like this:
style = sanitizer.bypassSecurityTrustHtml('html code with css styling');
And I can't paste a huge chunk of html/css code with new lines and such in there as a single string.
So what can I do here to stop Angular ignoring my style tags?
Upvotes: 0
Views: 249
Reputation: 657308
There is nothing preventing you from passing multi-line strings instead of single-line strings because there is no difference except that multi-line strings contain \n
or \r\n
.
Dart provides several ways in writing multi-line strings.
'1st line\n2nd line'
'1st line\n' + '2nd line'
'1st line'
'2nd line'
'''
1st line
2nd line
'''
var buffer = StringBuffer();
buffer.writeln('1st line');
buffer.write('2nd line');
buffer.toString();
Upvotes: 1
Reputation: 65
In Dart you can use '''string on multiple lines'''
to put your html/style/css code in and put that in the bypassSecurityTrustHtml function.
Upvotes: 1