How can I use ng-if to check if a string contains other substrings?
First, I want to use ng-if to check if the string contains other substrings "#teamA" or "#teamB", for example:
<ion-item ng-if="msg.indexOf("#teamA") > -1" class="teamA">
{{msg}}
</ion-item>
<ion-item ng-if="msg.indexOf("#teamB") > -1" class="teamB">
{{msg}}
</ion-item>
This code doesn't work. Second, I want each {{msg}} to have a different class assigned (teamA and teamB). Am I doing this correctly (if my works are ng-if)?
+3
source to share
2 answers