NAiVE_developer
NAiVE_developer

Reputation: 11

ng show condition syntax

<div class="darkblue-panel pn" ng-repeat="f in fc.frienddata">
    <div class="darkblue-header" ng-show="f.user_id=='currentUser.id'">
        <h5>{{f.user_id}}</h5>
    </div>
    <div class="darkblue-header" ng-show="f.friend_id=='currentUser.id'">
        <h5>{{f.friend_id}}</h5>
    </div>
</div>

currentUser is my rootscope variable which stores id when a user logs in.

friend_id and user_id are visible from my friend controller(which i have added) and so i know the values are present

but i dont know why the condition doesnt turn true cuz both the values show when i run this code

Upvotes: 0

Views: 731

Answers (2)

Peeyush Kumar
Peeyush Kumar

Reputation: 51

You can replace your code with my code.

<div class="darkblue-panel pn" ng-repeat="f in fc.frienddata">
       <div class="darkblue-header" ng-show="f.user_id==currentUser.id">
            <h5>{{f.user_id}}</h5>
       </div>
       <div class="darkblue-header" ng-show="f.friend_id==currentUser.id">
            <h5>{{f.friend_id}}</h5>
       </div>

We have to remove quotes because with quotes it's not a variable. After using quotes it will be now string.

Upvotes: 0

Disha
Disha

Reputation: 832

Remove quote of currentUser.id-

  <div class="darkblue-panel pn" ng-repeat="f in fc.frienddata">
   <div class="darkblue-header" ng-show="f.user_id==currentUser.id">
        <h5>{{f.user_id}}</h5>
   </div>
   <div class="darkblue-header" ng-show="f.friend_id==currentUser.id">
        <h5>{{f.friend_id}}</h5>
   </div>

Upvotes: 1

Related Questions