0

I need to show/hide label if length(description) < one row. Code is working ok, but if length < one row, label isn't hide. How to hide/show label?

If [[ demandAd.description ]] less than one line or less than one row(or length < 100), I need to hide label because it doesn't have a function at that time

<div class="demand">
    <p class="demand-ad-time">[[demandAd.createdAt | date:"dd.MM.yyyy."]]</p>
    <input type="checkbox" class="read-more-state" id="demandAd[[ demandAd.id ]]" />
    <p>[[ demandAd.description ]]</p>
    <label for="demandAd[[ demandAd.id ]]" class="read-more-trigger"></label>
    <hr>
    <div class="demand-chips">
        <div class="demand-chip" ng-repeat="demandAdLabel in demandAd.labelsWithPlaces track by $index">[[ demandAdLabel ]]</div>
    </div>
neverMind
  • 3
  • 3
  • Could you rewrite? I'm afraid I cannot understand what you exactly want? – justMe Aug 14 '18 at 13:21
  • if [[ demandAd.description ]] less than one line or less than one line, I need to hide because it doesn't have a function at that time – neverMind Aug 14 '18 at 13:29

1 Answers1

1

Hope I understand correctly, you want to hide a label when the text length is shorter than 100. You can compare the text length within ng-hide

<body ng-app="">

Hide base on text length: <input type="text" ng-model="myVar">

<div ng-hide="myVar.length >= 3">
<label>Hide when length >= than 3</label>
</div>

</body>

Here is a live sample code:

https://plnkr.co/edit/vHVXyNCTzPiuVwq2fyOG?p=preview

kitko112
  • 706
  • 1
  • 7
  • 14