Holiday Notice: Support will be provided on a limited scale from December 24th, 2024, to January 2nd, 2025. Happy holidays and a wonderful New Year!


Topic: How to code select two way binding using angular 2 components

faroooq.in pro asked 7 years ago


I am trying like this.
In component.html
----------------------
<mdb-select [options]="surahSelect" placeholder="సూరహ్" (change)="onChange($event.target.value)"></mdb-select>

In component.ts
-------------------

ngOnInit() {

this.surahSelect = [
{ value: '1', label: 'Option 1' },
{ value: '2', label: 'Option 2 444' },
];

}

onChange(newValue) {
console.log(newValue);   // ****Not get console output
}
With default select I am able to get. But with <mdb-select> I am not. Please share the sample example.


Sebastian Kaczmarek staff answered 7 years ago


Hi, reachfrq Material select is different than default one and as such, it behaves differently. If you want to trigger your function on selection change, bind it to selected event instead of change. See example:
<mdb-select [options]="surahSelect" placeholder="సూరహ్" (selected)="onChange($event)"></mdb-select>
Best regards, Sebastian

Please insert min. 20 characters.

FREE CONSULTATION

Hire our experts to build a dedicated project. We'll analyze your business requirements, for free.

Status

Answered

Specification of the issue

  • ForumUser: Pro
  • Premium support: No
  • Technology: MDB Angular
  • MDB Version: -
  • Device: -
  • Browser: -
  • OS: -
  • Provided sample code: No
  • Provided link: No
Tags