Change icon if the value is 0 or 1...ng-class - ng-ig

hi, i’m still there!!! :wink: i need your help, i need to show an ‘ion-checkmark-circled’ or an ‘ion-close-circled’ in a list item if the values of “archiviate.approvata” is true or false. (the value comes from db or Json) …I’ve tried to use this, but still the ‘ion-checkmark-circled’ for every item in the list
ng-class="{false: ‘ion-checkmark-circled’, true: ‘ion-close-circled’}[archiviate.approvata == 0]"
Many thanks

It’s other way around. 'className':condition

ng-class="{'ion-checkmark-circled': archiviate.approvata, 'ion-close-circled': !archiviate.approvata}

1 Like

thank you boss but doesn’t work…is always ion-close-circled…approvata can have 0 or 1…so false or true. how can i pass the parameter anche change icon??

Maybe to solve use controller?

Are you sure that approvata is number and not string? if it is string then it will always be true.

is Integer…in the db by default is 0… but i’ve do an insert to put some 1…I guess that there is a simple way to do this without controller just ng directive, but i can’ do this!!!

I don’t fully undesrtand your problem sorry. maybe you want to create a simple example in plunkr?

I appreciate your help… but it’s a lot of code… so make it simple…
I want to put an icon in a list (gettin item from the db by a query, all work fine), then
if the value of “approvata” is 0 i want an icon if is 1 i want a different one.
Sorry for my bad english

The example I showed above should work! try printing {{archiviate.approvata}} udner image to make sure that your value is indeed 0 or 1

i’ll try now…thanks again

HI BOSS WORKING I do a mistake in the query and doesn’t get approvata… THANK YOU SO MUCH!!!

Glad to hear everything is working now @fabiobalsamo . Just a possible point to consider for further simplification:

ng-class=" <$scope.archiviate.approvata or the current name of the value> ? 'ion-close-circled' : 'ion-checkmark-circled' "