javascript-AngularJS-在typeahead自动完成后填充其他字段
我是新来安格拉斯的。经过长期的努力,我发现了如何在Angularjs中使用Auto complete 现在,在从“自动完成”中选择值时,需要根据选择的值填充其他字段。即,在加载屏幕时,默认值将加载到文本框1和文本框2中。当用户通过文本框1中的自动完成选择新值时,则必须填充测试框2中的相应值javascript-AngularJS-在typeahead自动完成后填充其他字段,javascript,jquery,angularjs,Javascript,Jquery,Angularjs,我是新来安格拉斯的。经过长期的努力,我发现了如何在Angularjs中使用Auto complete 现在,在从“自动完成”中选择值时,需要根据选择的值填充其他字段。即,在加载屏幕时,默认值将加载到文本框1和文本框2中。当用户通过文本框1中的自动完成选择新值时,则必须填充测试框2中的相应值 <table> <tr> <th>Project number</th> <th>Project Name</t
<table>
<tr>
<th>Project number</th>
<th>Project Name</th>
</tr>
<tr ng-repeat="s in projectListObj">
<td><input name="projects" type="text" placeholder="Project Number" ng-model="s.project_number" typeahead="s as s.project_number for s in projectData | filter:{project_number:$viewValue}" | limitTo:8" class="form-control"></td>
<td><input type="text" name="proj-name" placeholder="Project Name" ng-model="s.project_name"/></td>
</tr>
</table>
项目编号
项目名称
你可以在你的ng模型上放一块手表。
例如,当您得到更改时,您将更新其他模型
$scope.$watch('BillDate1', function (newval, oldval) {
verfifyDate();
if (newval != undefined)
$scope.SearchModel.OtherVal[0] = newval;
if (newval == null)
$scope.SearchModel.OtherValTwo[0] = '';
});
一种更干净的方法是使用模板
<input type="text" name="Person Contacted"
typeahead="a as a.Name for a in getCustomerContactDetails($viewValue)"
model="s.allCustomerContact.Name" typeahead-on-select='s.onSelectContactPerson(allCustomerContact.Name)' >
就你的具体情况而言,我认为你想要的是把整体放在前面:
<td><input type="text" name="proj-name" placeholder="Project Name" ng-model="s" uib-typeahead="r as r.project_name for r in projectData"/></td>
这样,您可以同时显示数字和名称,因为您是在as语句中指定它的。这是一只扑克牌
我使用了项目名称,因为前面的字体看起来更清晰
希望对您有所帮助您可以在您的ng机型上安装一块手表。
例如,当您得到更改时,您将更新其他模型
$scope.$watch('BillDate1', function (newval, oldval) {
verfifyDate();
if (newval != undefined)
$scope.SearchModel.OtherVal[0] = newval;
if (newval == null)
$scope.SearchModel.OtherValTwo[0] = '';
});
一种更干净的方法是使用模板
<input type="text" name="Person Contacted"
typeahead="a as a.Name for a in getCustomerContactDetails($viewValue)"
model="s.allCustomerContact.Name" typeahead-on-select='s.onSelectContactPerson(allCustomerContact.Name)' >
就你的具体情况而言,我认为你想要的是把整体放在前面:
<td><input type="text" name="proj-name" placeholder="Project Name" ng-model="s" uib-typeahead="r as r.project_name for r in projectData"/></td>
这样,您可以同时显示数字和名称,因为您是在as语句中指定它的。这是一只扑克牌
我使用了项目名称,因为前面的字体看起来更清晰
希望对您有所帮助如果您在select上使用typeahead,性能会更好。要知道修改了哪个图元,可以传递模型<代码>我假设您正在使用引导angularyes中的typeahead。。。我正在使用ui引导。。。在选择的typeahead on select=“MethodInControl(s.projectNumber)”中,hw将知道旧值和新值??wat将是MethodInControl(s.projectNumber)的实现看一看编辑。也创建了一个plunker。我想这就是你想要的。Regardshey非常感谢兄弟……它的工作原理。我在select上使用了typeahead,它的工作原理:)在性能方面比在select上使用typeahead要好得多。要知道哪个元素被修改了,你可以通过模型。我假设你正在使用typeahead fromm bootstrap angularyes…我正在使用ui bootstrap…在选择的typeahead=“MethodInControl(s.projectNumber))中,我将知道旧值和新值吗????wat将是MethodInControl的实现(s.projectNumber)??请查看编辑。也创造了一个劫掠者。我想这就是你想要的。Regardshey非常感谢兄弟。。。。它起作用了。我在select上使用了typeahead及其工作方式:)