0

i have a little problem in my code, i work with angular and HTML, and when my "a> 0" my line becomes clickable and calls a function, and if my "a = 0" I have to display non clickable, knowing that my "a" is already recovered, I tried with a ng-if but I think I do not have the right syntax

I speak French, this message is translated by Google translation, I'm sorry if I made errers

what should I display when a> 0

          <tr height="25"
                name="a"  
                ng-click="startSearch(row,name)" 
                style="cursor: pointer">
                <td><a class="texte">a</a></td>
                <td align="right">{{a}}</td>
            </tr>

when a=0

            <tr height="25">
                  <td>a</td>
                  <td align="right">{{a}}</td>
            </tr>

what I try to do:

                  <tr height="25"
                   name="a"   
                   ng-click="startSearch(row,name)"
                   style="cursor: pointer"
                   ng-if="a > 0">
                  <td><a>a</a></td>
                  <td align="right">{{a}}</td>
                  </tr>
                  <tr height="25"
                  ng-if="a= 0">
                  <td>a</td>
                  <td align="right">{{a}}</td>
                  </tr>

I know it's not much, I'll just like to understand my mistake, thanks

1
  • I am not able to understand your question exactly but one issue is that in condition you are using ng-if="a= 0" it should be ng-if="a==0". = is assignment operator. Commented Jul 18, 2018 at 14:38

2 Answers 2

1

Also I'm not sure that you need two ng-if there. You can use ng-class, ng-style (but as for me use ng-class will be preferable). Wrote small example, hope that is what you expected.

<tr height="25" name="a" ng-click="startSearch(row,name)" ng-style="a>0 && {'cursor':'pointer'}">
  <td>
    <a ng-class="{'texte': a>0}">a</a>
  </td>
  <td align="right">{{a}}</td>
</tr>

<script>
  var startSearch = function (row, name, a) { //or try with ng-disabled instead 
    if (a <= 0)
      return;
      ...
  }
</script> 
Sign up to request clarification or add additional context in comments.

Comments

0

You have an error in this line: ng-if="a= 0", Actually we use = to affect a value to a variable and == to check the equality.

So this line should be ng-if="a == 0"

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.