0

I'm working on Angular, I have a page that could be shown in two languages, English and Arabic, in this page there is a table, in case the language is English I want a border-left, and in case the language is Arabic I want a border-right

<table style="width: 55%; border-right: 1px solid #000;">

how can I apply a condition on the style where:

if (lang == 'ar') style="width: 55%; border-right: 1px solid #000;"
else if (lang = 'en') style="width: 55%; border-left: 1px solid #000;"   

1 Answer 1

1

One way you could do this is to use the ngClass property (assuming you use Angular 2 or above). In that case you define those 2 style options as css classes and set the class of the table based on your lang variable.

<table [ngClass]="{'arabic':(lang==='ar'),'english':(lang==='en')}">

where "arabic" and "english" are the css classes defined in your stylesheet and on the right hand side of the classes there are expressions that apply the classes to the html element if they evaluate to true.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.