Looking for a way to disable ng-select using a directive. Does anyone have any suggestions on how to accomplish this?
Here is the code I have been working with, along with an example that I was trying to implement.
setTimeout(() => {
const selectElement = this.elementRef.nativeElement;
if (this.elementRef.nativeElement.tagName === 'NG-SELECT') {
console.log('selectElement :', this.elementRef.nativeElement);
this.renderer.setProperty(selectElement, 'disabled', true);
this.renderer.setProperty(selectElement, ' ng-select-disabled', '');
this.renderer.addClass(selectElement, 'disabled');
const inputEle = this.elementRef.nativeElement.querySelector('input');
this.renderer.setProperty(inputEle, 'disabled', true);
}
}, 1000);
I have tried various methods without success. Ideally, I would like to achieve this using directives. Any insights on how this can be achieved through directives?
- [disabled]="true" => works with ngModel
- [readonly]="true" => works with formControlName
- However, not working with directive.
If anyone has any tips or solutions, please share them!