作者: | 来源:互联网 | 2023-09-25 23:31
这个问题可能会被问到,但这并不能解决我的问题multi-select
。
在我的angular
项目中drop-down
,密钥包含database
,desktop
和account
。基于drop-down
键的值multi-select
ordrop-down
和inputbox
将被更改。
https://stackblitz.com/edit/angular-ivy-kioexw
我的问题:当我点击第一列作为database
它显示multi-select
,但在相同的第1行,如果我选择desktop
是database
multi-select
不墙根。请检查下图。
app.component.ts
import { Component, VERSION } from '@angular/core';
declare var $: any;
@Component({
selector: 'my-app',
templateUrl: './app.component.html',
styleUrls: [ './app.component.css' ]
})
export class AppComponent {
rowArray: Array = [];
newRowArray: any = {};
dbValue = ["mysql", "oracle", "mongo"];
desktopValue = [
{ id: "1", name: "dell" },
{ id: "2", name: "lenovo" },
{ id: "3", name: "hp" }
];
ngOnInit(): void {
this.newRowArray = {
title1: "",
title2: "",
dropdownDataDb: [],
dropdownDataDesktop: [],
isDropDown: true
};
this.rowArray.push(this.newRowArray);
console.log( $('.multiple-select').multiselect())
}
addRow(index) { this.newRowArray = {
title1: "",
title2: "",
dropdownDataDb: [],
dropdownDataDesktop: [],
isDropDown: true,
isText: false
};
this.rowArray.push(this.newRowArray);
console.log(this.rowArray);
return true;
}
deleteRow(index) {
if (this.rowArray.length == 1) {
return false;
} else {
this.rowArray.splice(index, 1);
return true;
}
}
//multiselect code
multiSelectJquery(){
setTimeout(()=>{
$('.multiple-select').multiselect({
includeSelectAllOption: false,
enableFiltering: true,
includeFilterClearBtn: false,
enableCaseInsensitiveFiltering: true
});
},1);
}
//multiselect code
changed(value: any, index: any) {
this.multiSelectJquery();
if (value == 1) {
this.rowArray[index].isDropDown = true;
this.rowArray[index].isText = false;
this.rowArray[index].dropdownDataDb = this.dbValue;
}
if (value == 2) {
this.rowArray[index].isDropDown = true;
this.rowArray[index].isText = false;
this.rowArray[index].dropdownDataDesktop = this.desktopValue;
}
if (value == 3) {
this.rowArray[index].isDropDown = false;
this.rowArray[index].isText = true;
}
}
}
应用程序组件.html
请帮我解决这个问题。提前致谢。