Search code examples
angularangular-ngselect

How can I change ng-select's items with directive?


I think I am missing something very basic, please forgive me for that but I really can't find the problem.

I just want to set ng-select's parameters (including items) with a directive. It's working on some static properties like clearAllText, but I can't use my directive to change items.

Here is sample: https://stackblitz.com/edit/ng-select-tests-share


Solution

  • I asked help from great developer friends and here is the solution

    hostSelectComponent.ngOnChanges({
      items: {
        previousValue: [],
        currentValue: hostSelectComponent.items,
        firstChange: false,
        isFirstChange: () => false,
      }
    });
    

    And complete app link: https://stackblitz.com/edit/ng-select-update-from-directive