How to use a variable in ng-if conditions?

138 Views Asked by At

I hope somebody can help me with this.

I'm building a messaging mobile application and i want to have my messaging style more interactive using this ng-if conditions but i'm having trouble using a variable outside my scope. "xyz" is my variable containing the email of the currentUser. Im using this xyz to make condition with the email inside my array. If the email of the message is equal to the currentUser which is the "xyz" variable the messages will be placed right and if not the messages will be placed left.

<div ng-repeat="m in messages">
      <div ng-if="m.email === xyz" id="getCss" class="chat self">
          <div class="user-photo"><img src="css/Image/image.png" style=" width: 60px; height: 60px;"></div> 
          <div class="chat-message">
          <p class="mailcss">{{m.email}}</p>
          <div class="messcss">{{m.message}}</div>
        </div>
      </div>
      <div ng-if="m.email !== xyz" id="getCss" class="chat friend">
          <div class="user-photo"><img src="css/Image/image.png" style=" width: 60px; height: 60px;"></div> 
          <div class="chat-message">
          <p class="mailcss">{{m.email}}</p>
          <div class="messcss">{{m.message}}</div>
        </div>
      </div>
    </div>

If i use string like '[email protected]' it works. I don't want to have it that way because it is only good for the user that owns the email how about the other users? Is there any way to solve this?

Thanks in advance. Happy coding!

0

There are 0 best solutions below