I'm using AngularJS, HTML, and Bootstrap/CSS to make my web application. I am trying to make an ordered list using the <ol>
tag with a <li ng-repeat …>
tag. I want to hide the numbers if there's only one item in the list. Any suggestions on how to approach this?
A snipet of my code:
<ul class="list-group">
<li class="list-group-item">
<ol>
<li ng-repeat="cog in cogs.Cognitivediagnosis">{{cog}} </li>
</ol>
</li>
</ul>
Add a class with ngClass
, for instance ol--no-number
, when there is only one item in the list:
.ol--no-number {
list-style-type: none;
}
<ol ng-class="{'ol--no-number': cogs.Cognitivediagnosis.length == 1}">
<li ng-repeat="cog in cogs.Cognitivediagnosis">{{cog}} </li>
</ol>
You could do a hack with CSS like this:
ol li:last-child {
list-style:none;
}
ol li + li {
list-style: inherit!important;
}
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.