简体   繁体   中英

Hide an inline style using angularJS

I need to hide only the inline style( style="float:left;" from ul tag) when data.unlock_scode value is present. ng-show="data.unlock_scode" is working fine in img tag and I can't use the same in ul tag then it will hide the entire ul section.

<ul style="float:left;">
   <li ng-show="data.upfront != ''">Test</li>
</ul>
<img src="u70007.jpg" ng-show="data.unlock_scode" style="float:left;">

You can use ng-style to have condition on your styles

<ul ng-style="{'float': data.unlock_scode ? 'inherit':'left'}">
   <li ng-show="data.upfront != ''">Test</li>
</ul>

Use ng-style

<ul ng-style="!data.unlock_scode" style="float:left;">
  .....
</ul>

better way is not to add inline style instead use ng-class

.someclass{
    add css here..
}

.someotherclass{
   add css here..
}    

ng-class="{someclass: !data.unlock_scode, someotherclass: data.unlock_scode}"

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM