angularng2-bootstrap

How to set default for ng2-select


data(?Array) - Initial selection data to set. This should be an object with id and text properties in the case of input type 'Single', or an array of such objects otherwise. This option is mutually exclusive with value.

This is from the website documentation. GitHub calls for initData which throws an error.

I am setting [data] with an array of valid options, but nothing is selected. Additionally, I am seeing this even fire every time the dropdown is opened.

This also does not work in single mode.

How can I pre-select 'options' for this control?

I am using this with RC.1. Other solutions on SO look like older versions of ng2.


Solution

  • https://valor-software.com/ng2-select/ under the multiple tab shows the use of a [data] element. This is incorrect as per the project readme.

    Replace [data] with [initData] and prepopulation works if the data is properly formatted.