Maria Gálvez
Maria Gálvez

Reputation: 307

Use pipes in css Angular 9

I want to put a text through the translate pipe, but the text is in the css in content.

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

This does not work:

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

Upvotes: 1

Views: 1507

Answers (1)

Pardeep Jain
Pardeep Jain

Reputation: 86790

Not sure if this going to work.

By using pipe you can change the content in the HTML part, so just bind to some attribute in the DOM and try to read from there in css like this -

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

For example you have DOM element, you need to add data attribute like mentioned below -

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

Upvotes: 4

Related Questions