mercredi 14 décembre 2016

Shortcut if within ng-click without else

I tried to find an answer to my question, but nothing helped me really. What I need is a shortcut if within a ng-click without an else expression, just with an if condition and what happens if this condition is true. So normally you would write a shortcut if like this:

ng-click="ctrl.isBoolean ? 'yes' : 'no'"

this is the same like this

if(isBoolean) {
    alert('yes');
} else {
    alert('no');
}

But now I just need the if condition and the part what happened if it's true. I tried this:

ng-click="ctrl.isBoolean ? 'yes'"

I thought this could be similar to this, because this one is possible:

if(isBoolean) {
    alert('yes')
}

It didn't work. Any ideas? I hope this is possible. Thanks

Aucun commentaire:

Enregistrer un commentaire