angular - How to style Angular4 custom components based on attribute? -
in polymer have concept add specific properties components, , style component associated attribute. (this way, differentiates them same component doesnt have attribute.
for example
polymer
<osb-retailer-details overlay></osb-retailer-details> <osb-retailer-details></osb-retailer-details>
and style <osb-retailer-details>
component overlay
attribute, following:
:host { box-sizing: border-box; display: block; margin: 0 0 15px; &[overlay] { margin-bottom: 0; } }
now question
in angular4, can same thing? pass attribute component, , style it, above?
thanks
yes, works same way. here's an example.
component definition:
@component({ selector: 'osb-retailer-details', template: '<div>hello world</div>', styleurls: ['src/retailer-details.css'] }) export class retailerdetails { }
src/retailer-details.css file:
:host { display: block; background-color: yellow; } :host[overlay] { border: 4px solid red; }
Comments
Post a Comment