ng-hide does not hide button

64 Views Asked by At

I want to hide the button if it's the delete folder and show if it's the inbox. The code below does not work as the button is always shown.

<div class="message-footer-height"  >
   <div class="custom-div-class" ng-click=""  > 
      <button class="custom-btn-default" 
         ng-hide="messageState.details && itemTappedValue = 'delete'"
         ng-class="{ 'msg-btn' : userMessageDetails.id === -1 }" 
         ng-click="deleteMessage()" >
            {{"button.delete"|translate}}
      </button>
   </div>
</div>

Thanks

2

There are 2 best solutions below

1
On BEST ANSWER

You need to use ==, == is loose equality and === is strict equality. Read more here https://developer.mozilla.org/en-US/docs/Web/JavaScript/Equality_comparisons_and_sameness

  <div class="message-footer-height"  >
    <div class="custom-div-class" ng-click=""> 
      <button class="custom-btn-default" 
        ng-hide="messageState.details && itemTappedValue == 'delete'"
        ng-class="{ 'msg-btn' : userMessageDetails.id === -1 }"
        ng-click="deleteMessage()">
          {{"button.delete"|translate}}
      </button>
    </div>
  </div>
0
On

You need double equal sign here itemTappedValue = 'delete'