Ich treffe Datenbank auf Dropdown-On-Change-Ereignis. Aber ich muss Tags nach dem Benutzer machen, wählt einen von ihnen aus.Kann angularjs Funktion nicht aus Dropdown aufrufen (select) mit select2
jsp Datei
<select id="multipleSelectLocation" data-placeholder="Select an option" ng-model="search" ng-change="searchlocation(search)" multiple="true" >
<option value="1">Option 1</option>
<option value="2" ng-repeat="location in userLocationList"> {{ location.city }}, {{location.state}}, <b>{{location.country}}</option>
</select>
Controller
$scope.searchlocation = function(search)
{
/*
if (search.length < 3) {
$scope.userLocationList = null;
return false;
}*/
$http.get(
location.protocol + '//' + location.host
+ contextPath + '/services/searchLocation', {
params : {
"search" : search
}
}).then(function(response) {
$scope.userLocationList = response.data;
if ($scope.userLocationList.length == 0) {
console.log('no location')
}
}, function(error) {
console.log("error while searching");
console.log(error);
});
}
$(document).ready(function() {
$("#multipleSelectLocation").select2();
});
, wenn ich einen Eingabetext und rufen searchLocation Controller haben es funktioniert gut. aber ich kann nicht vom Dropdown aufrufen.
Dank für Ihre schnelle Antwort. Aber warum ruft es die Funktion nicht auf? @beshoy, @ aks1357 – 987654321