I'm trying to get meteor to search for a username as the user types. For example typing in "a" would give users "admin", "adam" and "apple". "ad" would give "admin", "adam" etc..
In the controller I have:
this.helpers({
users() {
return Meteor.users.find({username:this.searchText});
}
});
and in the template I have
<ion-content>
<div class="new-chat.search">
<label class="item item-input">
<input ng-model="searchText" type="search" placeholder="Enter a username">
</label>
</div>
<div class="list">
<a ng-repeat="user in chat.users" ng-click="chat.newChat(user._id)" class="item">
<h2>{{ user.username }}</h2>
<h3>{{ user.profile.name }}</h3>
</a>
</div>
</ion-content>
If "this.searchText" is chaneged to 'admin' it will return admin.
Anyone know what I need to do to get this working?
You want to search for a partial match I guess. You could use a regular expression for that. https://docs.mongodb.com/manual/reference/operator/query/regex/
For example: