I have a property which should set the font size of a text element. I've tried this so far:
placeholder="Enter your TAX ID"
id="tax"
[(ngModel)]="tax_out"
[(ngModel)]="tax_in"
style="width: 100%; height: 100%; position: relative; bottom: 0px; fontsize: {{fontsize}}">
Unfortunately without success.
I get this in logcat:
"WARNING: sanitizing unsafe style value width: 100%; height: 100%;
position: relative; bottom: 0px; fontsize: (see
http://g.co/ng/security#xss)."
"[WARN] TypeError: Cannot set property style of [object Object] which
has only a getter"
"ERROR", source: ng:///AppModule/ModalContentPage.ngfactory.js (154)
"ERROR CONTEXT", source: ng:///AppModule/ModalContentPage.ngfactory.js (154)
解决方案
If it's just a single style, you can use property binding for this:
Please take a look at the ngStyle docs for more info if you need to set more than one style dynamically:
...
...
...