繁体   English   中英

Angular [ngStyle] 未考虑在内

[英]Angular [ngStyle] is not taken into account

我现在使用 Angular [ngStyle] 遇到问题。 除了没有出现在我的 mat-slide-toggle 组件上的样式组件之外,这里的一切似乎都有效。 tree.depth 和 tree.value 都已定义并正确显示。 我也尝试过将 tree.depth 相乘(因为它是一个相对较小的数字),但这似乎并没有太大变化。 有任何想法吗?

    <div *ngFor = "let tree of m_sortingtrees" class = "sliders">
        <mat-slide-toggle [ngStyle] = "{'margin-left': tree.depth * 10}">
            {{tree.depth}}
            {{tree.value}}
        </mat-slide-toggle>
    </div>

这是因为您将margin-left CSS 属性设置为无效值(也就是没有单位):

<div *ngFor="let tree of m_sortingtrees" class="sliders">
    <mat-slide-toggle [ngStyle]="{'margin-left': tree.depth * 10 + 'px'}">
        {{tree.depth}}
        {{tree.value}}
    </mat-slide-toggle>
</div>

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM