angglar 4のダイナミックスタイルのbackground-mage
17636 ワード
anguralr 4のbackground-mageの問題を参照してください.
Steyle binding
You can set inline style with a style binding.
Style binding syntax reembles propertybinding.Instead of an element property between braackets,start with the prefix
Steyle binding
You can set inline style with a style binding.
Style binding syntax reembles propertybinding.Instead of an element property between braackets,start with the prefix
style
、フォローアップby a dot(.
)and the name of a CSS style property: [style.style-property]
.src/ap/ap.com onent.content_copy
Some style binding styles have a unit extension. The following example conditionally sets the font size in “em” and “%” units .
src/app/app.component.html
content_copy
While this is a fine way to set a single style, the NgStyle directive is generally preferred when setting several inline styles at the same time.
, [style.styleAtribute] = "styleAtributeVar"
, background-image, image url base64 , ?
, ts
this.bgpictrue= `url(data:image/jpeg;base64,${event.message.picture})`
” sanitizing unsafe style value SafeValue must use [property]=binding: ,
Ionic2 TypeScript url , :
http://http://g.co/ng/security#xss
import {
DomSanitizer }
from
'@angular/platform-browser';
this.bgpictrue = this.sanitizer.bypassSecurityTrustStyle(`url(data:image/jpeg;base64,${ event.message.picture})`);;
・