【发布时间】:2014-06-11 08:55:00
【问题描述】:
我一直在使用 Angular,问题是我将这个 ng-model 放入了文本输入,同时我将它与这个自动完成指令一起使用,问题是我想更改输入一旦从自动完成中选择某些内容,而是在我需要的是描述时只输入数字,问题是当我输入所有数字时,它实际上将其更改为我想要的方式,有人可以帮助我,这是代码 $scope.trailer = {
options: {
minLength:2,
html: true,
source:"controllers/search.php?catalogo=trailers",
select: function(event, ui){
console.log(ui);
//$(this).val(ui.item.desc+' '+ui.item.clave).change();
$scope.formData.trailerid = ui.item.id;
$scope.formData.trailerclave = ui.item.clave;
$scope.formData.trailerdueno = ui.item.propietario;
$scope.formData.trailer = ui.item.desc;//+' '+ui.item.clave;
return false;
},
change: function (event, ui) {
if (ui.item == null) {
$scope.formData.trailerid = 0 ;
$scope.formData.trailerdueno = '';
$scope.formData.trailerclave = '';
$scope.formData.trailer = '';
}
}
},
methods: {}
}
和 html
<input type="text" class="form-control trailer" ng-model="formData.trailer" ui-autocomplete = "trailer" />
<span class="help-block">{{formData.trailer}}</span>
【问题讨论】:
标签: javascript jquery angularjs autocomplete