Last active
July 25, 2020 05:30
-
-
Save umairhm/66d4981b4aaf849c6504eb821de8010f to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!-- Using Angular's Style Binding expression --> | |
<!-- The value of 'padding' will have 'px' appended to it --> | |
<!-- But it will be limited only to 'px' and won't allow 'em', 'rem' or '%' --> | |
<!-- Similarly if we do [style.padding.em], it will be limited to 'em' only --> | |
<div class="default" [style.padding.px]="padding"> | |
Hello Coercion, this div has {{ padding }} padding! | |
</div> | |
<!-- Using Angular's Style Binding expression --> | |
<!-- We don't use the unit expression, and leave it open for any value to be passed --> | |
<!-- We can do similar to above example using a custom conversion method --> | |
<!-- But again, we will limit to a certain unit, e.g. 'px' or 'em' --> | |
<div class="default" [style.padding]="padding"> | |
Hello Coercion, this div has {{ padding }} padding! | |
</div> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { Component, Input } from '@angular/core'; | |
@Component({ | |
selector: 'css-pixel-coercion', | |
templateUrl: './css-pixel-coercion.component.html' | |
}) | |
export class CssPixelCoercionComponent { | |
@Input() padding: string; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment