From the documentation:
Setup your directive like so:
<ui-select multiple ng-model="yourmodel" theme="select2" ng-disabled="disabled" style="width: 800px;">
<ui-select-choices repeat="address in addresses track by $index"
refresh="refreshAddresses($select.search)"
refresh-delay="0">
</ui-select-choices>
</ui-select>
The refreshAddress function is going to be called when searching. Here is what that would look like with an async call to the server:
function MyCtrl(){
$scope.addresses = [];
$scope.refreshAddresses = function(address) {
var params = {address: address, sensor: false};
return $http.get('http://maps.googleapis.com/maps/api/geocode/json', {params: params})
.then(function(response) {
$scope.addresses = response.data.results
});
};
}
This example is calling a google api endpoint to get data. You would call your endpoint instead.
Here's a link to the documentation: https://github.com/angular-ui/ui-select/wiki/ui-select