我想在Angular 2中使用多選,但是我還沒有找到可以正常工作的多選。angular 2 s-multiselect-dropdown不能在表單元素內工作
ng2-complete
(不打電話的時候表單內onselect
功能)ss-multiselect-dropdown
(不叫ngModelChange
當表單內)angular2-multiselect
(表單內時不顯示風格以及)
我需要使用表單元素,因爲我想驗證控件
s-multiselect-dropdown
MultiSelect和Filter模式也不起作用。
<form #f="ngForm" novalidate>
<ss-multiselect-dropdown [options]="paymentTypeInfo"
[ngModel]="selectedTexts" (ngModelChange)="onChange($event)" >
</ss-multiselect-dropdown>
<button type="submit" class="button"(click)=savePersonDetails(f.valid)>Submit</button>
<form/>
paymentTypeInfo: PaymentTypeInfo[] = [];
selectedTexts: number[] = [];
this.PaymentTypeInfo= [
{ "id": 1, "name": "India" },
{ "id": 2, "name": "Singapore" },
{ "id": 3, "name": "Australia" },
{ "id": 4, "name": "Canada" },
{ "id": 5, "name": "South Korea" },
{ "id": 6, "name": "Germany" },
{ "id": 7, "name": "France" },
{ "id": 8, "name": "Russia" },
{ "id": 9, "name": "Italy" },
{ "id": 10, "name": "Sweden" }
];
savePersonDetails(isValid: boolean) {
if (isValid)
{
console.log("selectedTexts");
console.log(this.selectedTexts);
}
}
public onChange(): void {
alert("hi");
console.log(this.selectedTexts);
}
請包含在產品ude您的html和角碼 –
請分享您的代碼 –
您關閉
而不是 –