- c - 在位数组中找到第一个零
- linux - Unix 显示有关匹配两种模式之一的文件的信息
- 正则表达式替换多个文件
- linux - 隐藏来自 xtrace 的命令
flex-layout 没有在宿主元素上应用内联样式,宿主元素通过@HostBinding 获取它们的 flex-layout 属性
@Component({
selector: 'column-node', //flex-layout not working on host elements
host: { '[@visibility]': 'visibility' },
template: `<ng-content></ng-content>`,
})
export class LayoutColumnNodeComponent {
@HostBinding('attr.fxLayout') fxlayout = 'column';
}
fxLayout
在 DOM 中添加了属性 <column-node fxLayout="column">
但未应用 flex-layout 内联样式。
不能使用独立的选择器 <column-node>
在你的html
您所有的自定义选择器,无论您在一个页面中有多少个,都需要内联弹性属性标记。
<column-node fxLayout="row" fxLayoutAling="start start" fxFlex.xs="100" fxFlex.sm="50" fxFlex.md="33" fxFlex.lg="33" fxFlex="25">
使用所有这些 flex 标记将很难扫描此代码....
最佳答案
我认为问题在于,当元素上没有直接的 fxLayout
属性时,不会应用 LayoutDirective
。
@Directive({selector: `
[fxLayout],
[fxLayout.xs]
[fxLayout.gt-xs],
[fxLayout.sm],
[fxLayout.gt-sm]
[fxLayout.md],
[fxLayout.gt-md]
[fxLayout.lg],
[fxLayout.gt-lg],
[fxLayout.xl]
`})
export class LayoutDirective extends ...
仅当属性静态添加到模板时才应用指令。
通常无法将指令应用于宿主元素。
关于angular - @angular/flex-layout 不适用于@HostBinding,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41401882/
我正在寻找使用异步值处理 HostBinding 的最佳方法。 在 Angular v2.1.2 之前,我可以像这样在 @Directive 装饰器中使用 host 属性: @Directive({
我已在我的 Angular 6 应用程序中成功使用 @HostBinding 将属性应用于主机组件,就像在变量为真时应用类一样: @HostBinding('class.compact-ui') is
找不到它的文档。 从示例中我得到了 3 个案例: @HostBinding(" attr .something") @HostBinding(" class .something") @HostBin
我想知道在使用组件的 @HostBinding 和 host 属性之间是否存在巨大差异(如果存在,差异是什么?)? 我在使用动画时一直在问自己这个问题,因为我在这些情况下(看起来很接近): @Comp
我在世界各地的互联网上闲逛,现在尤其是 angular.io style docs ,我找到了很多对 @HostBinding 和 @HostListener 的引用。看起来它们非常基础,但不幸的是目
我有一个带有加载、错误显示和实际内容的包装器。根据某些输入,我想显示一个或另一个。 我想测试是否有任何错误添加了 'center__holder' 类 组件: @Component({ selec
我正在使用 @HostBinding 将函数的结果绑定(bind)到宿主元素的可见属性: @HostBinding('attr.visible') private get visibleAttr():
我正在尝试将 CSS 类 foo 绑定(bind)到我的主机组件,使用 @HostBinding 取决于我在动态 变量。但无法使其正常工作。 这是我已经尝试过的: export class MyCom
我有这段代码在主机上设置了一个类: @HostBinding('class.fixed') true; 我想做的是使它成为一个我可以修改的变量类。我该怎么做? 最佳答案 这不能变成可变的。 您可以做的
是否可以像此示例一样绑定(bind) @HostBinding 值? @Input() user: User; @HostBinding("class.temp") user.role == "Adm
我有一个有用户登录和注销功能的 Angular 应用程序。在用户登录之前,我会显示一个欢迎页面作为主页。我只想在欢迎页面上启用背景图像。用户登录后,背景图像必须消失。当用户注销时,他将被重定向到欢迎页
我有一个使用 @HostBinding 设置类的组件: @HostBinding('class.dark-1') true; 效果很好。但是,现在我需要在我的组件中创建一个函数来动态更改类。 例如,当
我使用 @HostBinding 与 Chrome 的拖放 API 一起设置一个类,如下所示: @Directive({ selector: '[sortable-article]' }) expor
我的根本问题是我需要设置一个异步函数 alters an attribute of the host .由于 @HostBinding 没有异步能力,我在组件上设置了一个实例变量,绑定(bind)它,
flex-layout 没有在宿主元素上应用内联样式,宿主元素通过@HostBinding 获取它们的 flex-layout 属性 @Component({ selector: 'colum
这个问题在这里已经有了答案: In RC.1 some styles can't be added using binding syntax (2 个答案) 关闭 6 年前。 使用 @HostBin
问题: 是否可以使用 @HostBinding 来添加、删除或切换宿主元素上的类,而不是删除预先存在的类,特别是当类需要动态切换? 例如,这将添加 light 类并且不会中断之前的类;但是,light
我正在尝试使用 @HostBinding 装饰器在宿主元素上设置 ngIf。 class ListItem { @HostBinding('ngIf') active: boolean = f
我有一个基于 bootstrap3 的模板,我正在向它添加 angular2。 当更改从登录到应用程序其余部分的路由时,我需要更改正文的类,这是我的根组件选择器。 根组件 @Component({
在我的 TSLint 文件中,我有: "no-unused-variable": true 在我的组件中,我有时会: // tslint:disable-next-line:no-unused-var
我是一名优秀的程序员,十分优秀!