Joe Joe - 9 months ago 62
AngularJS Question

ngif is not working properly

I want to use ngif to check some int that comes back from a function, and if its bigger then 0 I want to present it, so this is what I did:

<b>Name:</b>{{person.getName()}}<b>balance left:</b>
<div *ngif="person.getBalance()>0">{{bulk.getBalance()}}</div>

but i get a blanc page, but if i remove the ngif its fine, but I need it, what am I doing wrong?

this is a data that comes from an array called "person"



You misspelled it. Try removing the * and put a - between ng and if.

<div ng-if="person.getBalance()>0">{{bulk.getBalance()}}</div>

I think that that doesn't work either because you're evaluating a method. Instead store Balance in a variable like this:

<div ng-if="person.balance>0">{{bulk.balance}}</div>

Execute the getBalance method in your controller.