这就是我想要做的
If value(depth) = 1 --> margin-left:10px
else value(depth) = 2 --> margin-left:20px
else value(depth) = 3 --> margin-left:30px
ex) Value * 10px
我自己编写了以下代码,但它不起作用 .
<div class="comment" *ngIf="comment.depth === 1" style="margin-left:10px">
<div class="comment" *ngIf="comment.depth === 2" style="margin-left:20px">
<div class="comment" *ngIf="comment.depth === 3" style="margin-left:30px">
我应该如何更改代码才能使其正常工作?
1 回答
您可以使用依赖于当前深度值的样式 .
这是一个得到这个想法的例子:
HTML
TS