MultiAutoComplete does not update when selectedItems changed elsewhere

Posted by: maarten on 1 May 2018, 12:10 am EST

    • Post Options:
    • Link

    Posted 1 May 2018, 12:10 am EST

    I want to use MultiAutoComplete in an Angular 1.X application where selected items can also be added from other controls.

    But when selectedItems is changed outside MultiAutoComplete, the changes are not immediately visible. Only after you start typing in MultiAutoComplete the updated selection is shown. This simple Plunk reproduces the problem:

    http://plnkr.co/edit/CZ6fHHYe2O5askEzszai?p=preview

    Is this something that should be fixed in the control, or in my application?

  • Posted 1 May 2018, 9:22 pm EST

    Hi,

    You need call the invalidate method after you update the selected items programmatically.

    Please refer to the following updated plunker :- http://plnkr.co/edit/Ig72buog49INGJmEA7b1?p=preview

    ~Manish

  • Posted 3 May 2018, 12:52 am EST

    Hi Manish,

    Thank you for your suggestion. While implementing your suggestion I found out something else.

    When I create a new array when adding, changing the reference of the array, it also works. See this plunk: http://plnkr.co/edit/nXU1mzD9fr7VJGgPCQnd?p=preview

    Perhaps I should have used immutable objects, also because it is best practice with AngularJS one-way binding.

    Thanks,

    Maarten

  • Posted 3 May 2018, 1:49 pm EST

    Thanks Marteen, for notifying that your issue has been resolved and for sharing another approach which may be helpful to others.

    ~Manish

Need extra support?

Upgrade your support plan and get personal unlimited phone support with our customer engagement team

Learn More

Forum Channels