在 css Angular 9 中使用管道



我想通过翻译管道放置文本,但文本在内容中位于 css 中。

.files:before {
position: absolute;
content: "Drag your files here";
}

这不起作用:

.files:before {
position: absolute;
content: {{'file.text' | translate}};
}

不确定这是否有效。

通过使用管道,您可以更改 HTML 部分中的内容,因此只需绑定到 DOM 中的某个属性并尝试从那里读取 css 中,如下所示 -

.files:before {
position: absolute;
content: attr(data-lang)
}

例如,你有 DOM 元素,你需要添加如下所述的数据属性 -

<p data-lang="en">Any content here </p>

最新更新