Topic: mdb-select2 Serchable
Expected behavior I cannot initialize mdb-select 2 when I use search text from a pre-selected value. Actual behavior Doesn't initialize any values. Resources (screenshots, code snippets etc.)
{{c.label}}TS file: this.filteredOptions = this.searchText.pipe( startWith(''), map((value: string) => this.filter(value)) ); filter(value: string): any[] {
const filterValue = value.toLowerCase();
//console.log("Filter:", this.pList.filter((option: any) => option.label.toLowerCase().includes(filterValue)));
return this.pList.filter((option: any) => option.label.toLowerCase().includes(filterValue));
}
this.property_id="5";
Open
- User: Pro
- Premium support: Yes
- Technology: Angular
- MDB Version: 9.2.0
- Device: Desktop
- Browser: Chrome
- OS: Windows
- Provided sample code: No
- Provided link: No
Arkadiusz Idzikowski staff commented 8 months ago
Please provide full HTML and Typescript code on which we will be able to reproduce this problem.
pparesh pro premium commented 8 months ago
{{c.label}} {{c.value}} Reported By
pparesh pro premium commented 8 months ago
import { Component, ViewChild, OnInit } from '@angular/core'; import { RDService} from './../../_services/rd.service'; import { RequestService} from '../../_services/request.service'; import { HttpResponse } from '@angular/common/http'; import { ViewEncapsulation } from '@angular/core'; import { ActivatedRoute } from '@angular/router'; import { Router } from "@angular/router"; import {FormControl} from '@angular/forms'; import { User } from './../../_models/user.model'; import {AuthenticationService} from '../../_services/authentication.service'; import { IMyOptions,ToastService } from 'ng-uikit-pro-standard'; import {saveAs as importedSaveAs} from 'file-saver'; import { Subject, Observable } from 'rxjs'; import { startWith, map } from 'rxjs/operators';
@Component({ selector: 'app-wo', templateUrl: './wo.component.html' }) export class WoComponent implements OnInit { user = this.AS.currentUserValue; constructor(private REQ:RequestService,private rd:RDService, private activeRoute: ActivatedRoute, private router: Router, private AS: AuthenticationService, private toastr: ToastService) { }
searchText = new Subject(); filteredOptions: Observable;
urlPrefix=""; queryParams = {}; showModal = false; file_info=""; add_docs = 0; owner_id=-1; owner_type="WO"; modalTitle="";
reportedby_dirty=false; contact_name_dirty=false; contact_info_dirty=false; wo_id = -1; tenant_id=-1; tenancy_id=-1; property_id="-1"; user_id=-1; wo = {}; property=[]; tenancy=[]; pList = []; // all properties property_info=""; woDocuments = [] woHistory=[]; tx_date = ""; dtList = this.rd.GetDates(); wosList = this.rd.GetWOStatus(); userList = this.rd.GetUsers(0); priorityList= this.rd.GetWOPriorities(); rmList= this.rd.GetWOReportingMethod(); rmMethod=""; woStatus=""; coordinator=""; priority="";
imageList = this.rd.GetImages();
ngOnInit() { this.wo['reportedby'] = this.user.firstName+" "+this.user.lastName; var r = "0"; this.urlPrefix = this.router.url.slice(0,this.router.url.lastIndexOf('/')+1); this.getProperties();
}
filter(value: string): any[] {
}
getWO() { const qry = { "params": { "wo_id": this.wo_id } };
}
Arkadiusz Idzikowski staff commented 8 months ago
The code you provided is hard to read and we can't use it to reproduce the problem because there are too many variables to which we don't have access. Please update the formatting (you can edit your first post and add the code there) and provide a simple example on which we will be able to reproduce the problem or send a simple demo app to a.idzikowski@mdbootstrap.com.
I just checked the example with a search on my end and it looks like options are displayed correctly.