-
Notifications
You must be signed in to change notification settings - Fork 767
flex-layout is not applying the inline styles on host elements #76
Comments
Added two attributes to the @HostBinding('attr.fxLayoutAlign') alignment = 'start start'; ` |
K. While this was not an intended usage, it does present some odd ideas. |
With your hostBindings, your are hoping to set this equivalent? <test-app fxLayout="column" fxLayoutAlign="start start"></test-app> but you have only one child within |
My expectation is that
{
box-sizing: border-box;
max-height: 100%;
display: flex;
flex-direction: row;
-webkit-box-orient: horizontal;
-webkit-box-direction: normal;
justify-content: space-between;
align-items: center;
align-content: center;
-webkit-box-align: center;
}``` |
I am not certain HostBinding(s) will actually create a compiled, active directive. Most likely it considers the attr.fxLayout to be a static attribute (which is NOT compiled). This is a known bug/feature request on Angular core. |
This will cause a huge amount of redundant markup in my html files. For every node I will have to code inline all the flex properties rather than setting them once in the reusable component. my html file will be very busy with all this repeated flex attributes on each selector. Seems I should be able to set this once in the column-node.component.ts <column-node fxLayout="row" fxLayoutAlign="space-between center" fxFlex.xs="10" fxFlex.sm="25" fxFlex.md="50" fxFlex.lg="100">
...COLUMN NODE CONTENT...
</column-node> //could be many nodes cluttering up the file, making it difficult to scan.
` |
This feature is under consideration by angular core team angular/angular#11716 |
@ThomasBurleson the original issue was angular/angular#14114 which is the same that issue here. |
@ghoullier - Thank you for the clarification. Definitely seems to be a Angular issue: Refs angular/angular#11716 |
Is there any update in this issue? |
@Twois - this issue is not a flex-layout issue, but rather an Angular compiler issue. |
I understood that it sets raw style, but seeing my immediate problem go away I didn't think about the other stuff, thanks for pointing it out. |
Is it possible to add some kind of marker (^) in front the
|
@mattiLeBlanc - No. This is a bug with Angular itself. If your component wants to to have a vertical flow, then simply wrap your component html within a wrapper: <div fxLayout="column">
.... your original template content...
</div> |
@ThomasBurleson Did angular fix this bug, and that's why this issue is now closed? |
@ThomasBurleson i installed flexlayout modules, but its not working in my project can you help what i have to do, Not generating inline style for flexlayout="column" |
you need to follow the API...https://github.com/angular/flex-layout/wiki/API-Documentation |
@ThomasBurleson Question (I hope not a silly one), is it possible that 2.0.0-beta.10 is automagically adding UPDATE
Very interesting :)
is also not going to stretch the component DOM element. The only way I can do it now is manually assigning a class via |
I have the same problem. I have attached the result of my page. I have this main component html <div fxLayout="row" fxLayoutWrap fxLayoutAlign="start start">
<template #widgetContainer></template>
</div> And in the js I fire the This is the content of children HTML: <div [fxFlex]="this.widget.options.columns">
<mat-card>
<mat-card-title>{{this.widget.options.title}}</mat-card-title>
<mat-card-content>
Grid {{this.widget.options.columns}}
</mat-card-content>
</mat-card>
</div> And JS: @Component({
selector: 'grid',
templateUrl: './grid.component.html'
})
export class GridComponent implements OnInit {
public widget: WidgetService;
public constructor(
public viewContainerRef: ViewContainerRef
) {
this.widget = new WidgetService({
title: "Tabella " + this.getIntNum(),
originalX: 1,
originalY: 1,
x: 1,
y: 1,
base_columns: 50,
base_rows: 2,
columns: this.getIntNum() % 2 == 0 ? 50 : 25,
rows: 2,
type: "grid",
resizable: true
});
}
private getIntNum() {
let n = Math.floor(+(Math.random()*100));
return n;
}
public ngOnInit(): void {
}
} As you can see the card item not fit the correctly width of my container (container is a full browser page) |
We have two issues discussed here:
The Host-Directive issue may be fixed... but not in the near-term future. A reasonable interim workaround is the manual use of CSS class for the host-element. We will reopen this issue to continue exploring other options. |
@ThomasBurleson There is already at least one directive in flex-layout (I think fxFlex?) which reaches "up" to its parent to apply CSS styles in certain cases. What about another use of that same notion? There could be a directive which can be used on a top-level element within the component, which reaches upward to configure flex properties on the component element itself. This could be considered hackish... but has the merit that it could be implemented now, rather than after core Angular signs a high quality solution for the host directive issue. |
Workaround will be to do it by hand, like this. export class SpacerComponent implements OnInit {
flexDirective: any;
constructor(
monitor: MediaMonitor,
elRef: ElementRef,
@Optional() @SkipSelf() protected _container: LayoutDirective,
@Optional() @SkipSelf() protected _wrapContainer: LayoutWrapDirective,
renderer: Renderer2,
) {
this.flexDirective = new FlexDirective(monitor, elRef, renderer, _container, _wrapContainer);
this.flexDirective.flex = '1 1 auto';
}
ngOnInit() {
this.flexDirective.ngOnInit();
}
} |
@gogakoreli - that is twisted and creative. LOL. |
This has been delayed until post-ivy implementation in Angular core. |
As an update to this issue, as alluded to by @mhevery in angular/angular#11716, this feature will not be implemented in Core. The alternative that is being considered is here: angular/angular#8785. Please follow that issue for future updates. I'm closing this issue and locking the conversation since it's very much not a Flex Layout issue. |
flex-layout is not applying the inline styles on host elements where the host elements are getting their flex-layout attributes via @HostBinding
fxLayout
attribute is added in DOM<column-node fxLayout="column">
but flex-layout inline styles are not being applied.The text was updated successfully, but these errors were encountered: