【发布时间】:2016-02-01 02:28:44
【问题描述】:
app.js
$scope.add = function () {
$('#btn').click(function() {
// insert a SPAN tag with class="spn" at the end in all DIVs with class="cls"
$scope.data=[];
var add=' <input type="text" name="currency" id="autocomplete">' ;
$('div.cls').append(add);
i++;
$scope.count++;
});
}
$scope.autocomplete=function(){
var currencies = [
{ value: 'Afghan afghani' },
{ value: 'Albanian lek'},
{ value: 'Algerian dinar'},
{ value: 'European euro' }
];
// setup autocomplete function pulling from currencies[] array
$('#autocomplete').autocomplete({
lookup: currencies,
});
}
html
<div class="cls" id="idd"></div>
<button type="button" class="btn btn-default btn-sm" id="btn">
<span class="glyphicon glyphicon-plus"></span> Add
</button>
这个自动完成功能在不使用 as append 的情况下运行。但是当我在像上面那样附加文本字段后使用它时它不起作用。谁能帮助我。
【问题讨论】:
-
什么意思??你的意思是,点击按钮后,再点击,就没有添加??
标签: javascript jquery angularjs angularjs-directive