If else in ionic


#1

can I use if else condition in ionic to compare a string that I entered to the input type with another string


#2

If you have read on Ionic … you might have figured out that Ionic uses AngularJS wich is a Javascript framework. And javascript has if else :slight_smile:


#3

of course you can, but this is not ionic specific, it’s more an angular/javascript specific problem. In your controller try something like this:

$scope.$watch("myInputName", function(newValue) {
//the selection comes here:
if(newValue === 'myCompareString') {
//do anything you want
}
});