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
1 answer
asked Sep 3, 2019 in Web Technology by Sammy (47.6k points)
0 votes
1 answer
0 votes
1 answer
+2 votes
1 answer

Browse Categories

...