[英]How to multi-select option from dropdown
I have one input box and besides that, I have on image. 我有一个输入框,除此之外,我还有图像。 After clicking on image, I am opening one drop-down there with some options which is coming from controller.
单击图像后,我将在其中打开一个下拉菜单,其中包含一些来自控制器的选项。 If I select something from drop-down, it is going to enter in text-box.
如果我从下拉菜单中选择某项,它将在文本框中输入。 Like that we can insert multiple option from drop-down with comma separated one.
这样,我们可以从下拉菜单中插入多个选项,并以逗号分隔。 I am able to enter single selected option from drop-down to text-box.
我可以从下拉菜单到文本框输入单个选择的选项。
I need help is : 我需要帮助的是:
This is all I need to do in Angular js. 这是我在Angular js中需要做的所有事情。
Below is my controller: 以下是我的控制器:
$scope.onDropDdownChange = function (dropdownFieldName, textFiledName,splitSelItem) {
let rpInfo = $scope.restrictedPartyInfo;
let selItem = rpInfo[dropdownFieldName] ? (splitSelItem ? (rpInfo[dropdownFieldName]).split("-")[0] : rpInfo[dropdownFieldName]) : '';
if(rpInfo[textFiledName]) {
var isExist = rpInfo[textFiledName].indexOf(selItem);
if(isExist)
rpInfo[textFiledName] += ',' + selItem;
} else {
rpInfo[textFiledName] = selItem;
}
};
And below is my HTML Part: 下面是我的HTML部分:
<td width="10%" class="gridInfoAddEditTableData">Customer Types*</td>
<td width="9%" class="gridInfoAddEditTableData">
<img id="followbutton" ng-src="{{followButtonImg}}" alt="Show Hide"
ng-click="ShowHideCusttyp();toggleImageCustTyp()" ng-model="restrictedPartyInfo.ShowHideCusttyp">
<input type="text" id="customertypes" style="width:54%" ng-click="ShowHideCusttyp();"
ng-model="restrictedPartyInfo.customerType"
ng-keydown="ShowHideCusttyp();"/>
</td>
<td align="center" class="gridInfoAddEditTableData">
<select multiple ng-show = "Visible" name="customerTypess" ng-change="ShowHideCusttyp();onDropDdownChange('customerTypes','customerType',false);"
ng-model="restrictedPartyInfo.customerTypes"
style="position: relative; align: center; top: 1px; left: 245%; width: 150%; height: 65px;"
ng-init="customerTypess ='val_customerTypess'" >
<option ng-repeat="custtyp in customerTypes" value="{{custtyp.clientTypeCode}}">{{custtyp.clientTypeCode}} – {{custtyp.clientDescription}}</option>
</select>
</td>
For 1. Use Multiple tag of html , You have to use Ctrl + mouse click https://www.w3schools.com/tags/tryit.asp?filename=tryhtml_select_multiple and you will get array of selected data which use can show in Comma Seprated Way 对于1.使用html的多个标记,您必须使用Ctrl +鼠标单击https://www.w3schools.com/tags/tryit.asp?filename=tryhtml_select_multiple ,您将获得所选数据的数组,这些数组可以使用逗号显示分隔方式
For 2. Use can use loop after selection of multiple data from dropdown You can restrict during Selection like if already in array then remove, NG-change may help Remove duplicate data coming from Server :) 对于2。在从下拉列表中选择多个数据后,Use可以使用循环。您可以在Selection期间进行限制,例如是否已经在数组中然后进行删除,NG更改可能会帮助删除来自Server的重复数据:)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.