Intellipaat Back

Explore Courses Blog Tutorials Interview Questions
0 votes
2 views
in Web Technology by (47.6k points)

I am handling my issue like this:

ng-style="{ width: getTheValue() }"

But to avoid having this function on the controller side, I would much prefer to do something like this:

ng-style="{ width: myObject.value == 'ok' ? '100%' : '0%' }"

How can I do this?

1 Answer

0 votes
by (106k points)

For AngularJs ng-style with a conditional expression, you can use the below-mentioned code:-

.largeWidth {

 width: 100%; 

.smallWidth { 

width: 0%; 

ng-class="{largeWidth: myVar == 'ok',smallWidth: myVar != 'ok'}"

Related questions

0 votes
2 answers
0 votes
1 answer
0 votes
2 answers

1.2k questions

2.7k answers

501 comments

693 users

Browse Categories

...