@lado wrote:
Hello,
Type ScriptinIonic2application:How to get item from
this.myListofcheck-boxesby another element. If I add elements toprivate myList: any = [];this way:this.myList.push({ id: i, name: myName, UID: obj.UID },);where
id: iis a loop iteration number,name: myNameis a username, andUID: obj.UIDis a non sequential specific number, thenmyListcontent should be:id| myName | UID ------------------- 0 | sally | 345 1 | vikram | 5487 2 | kim | 12 3 | roy | 2134Goal is to find
ID: obj.IDbymyNamevalue. For example getUIDvalue: 12 bymyName: kimit is
undefinedand does not returns existed value, this way :findByName() { const found = this.myList.find(({ name }) => this.searchName === name); if (found) { return found.UID; } else { return null; } }then I’ve tried differently, with adding:
this.myList[myName] = { id: i, name: myName, UID: obj.UID };to list:myList: {[name: string]: { id: number, name: string, UID: string }} = {};but it same resultundefined:findByName(searchName: string) { const found = this.myList[searchName]; if (found) { return found.UID; } else { return null; } }
Posts: 2
Participants: 2