i am wondering if there is any possibility to set the ion-label placement attribute (floating, stacked or fixed) dynamically?
There doesn’t seem to be some property like [placement]="...", or is there?
I also tried to implement this via a custom directive with this.renderer.setElementAttribute(this.elementRef.nativeElement, "floating", "''"); on ngInit but this doesn’t seem to work either.
If i didn’t get it wrong, to achieve this, one has to:
a) dynamically set/unset element class of parent ion-item to ‘item-label-’ + floating/fixed/stacked (because this is normally only done on change of the contentchild element)
AND
b) dynamically set/unset the attribute values for floating/fixed/stacked of the ion-label, as these only are evaluated in the constructor, but referenced as stylesheet selectors in the css.
I currently achieve the desired behavior with several simple ngIf statements like
Does not work the desired way and has other negative side effects:
as i already said one has to also bind [attr.floating]="placement === 'floating' ? '' : null" (and the same for fixed and stacked) because label.scss relies on these attributes.
binding ion-item [class]="'item-label-' + placement" seems to brake other formgroup styles (disabled class is not set on disabled controls any more!)
so, i think i’ll sadly have to stick with the unhandy *ngIf approach as long as there is no bindable placement attribute…