3

I'm trying to use the angular 2 dropdown multiselect library with reactive forms.

I have followed the tutorial for reactive model and have this:

this.myOptions = [
    { id: 1, name: 'English' },
    { id: 2, name: 'French' },
];

this.form = this.formBuilder.group({
    langs:[1, 2]
});

And in my html (in pug):

ss-multiselect-dropdown([options]='myOptions', formControlName='langs')

And get the following error: TypeError: this.validator is not a function

So I've tried:

this.form = this.formBuilder.group({
    langs:this.formBuilder.array([1, 2])
});

And get the following error: TypeError: control.registerOnChange is not a function

What am I doing wrong? Is this a bug?

You can see a plunker here

1 Answer 1

4

As I understand from your Question that, You want to select both values on init.

this.myForm = this.formBuilder.group({
  optionsModel: [[1,2]] // Default model
});

Both values will be selected default

Updated Plunker : https://plnkr.co/edit/tvLYUzgsCkXODXX6qKrN?p=preview

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.