0

ERROR TypeError: control.registerOnChange is not a function in html code

   <form [formGroup]="editRoleForm" (ngSubmit)="onEditRole()" class="col s12" materialize>
      <div class="row">
         <select multiple formControlName="sp_id" id="permission_id" materialize="material_select" [materializeSelectOptions]="permissions"> // in this part ERROR TypeError: control.registerOnChange is not a function
          <option value="" disabled selected>Select Permissions</option>
          <option *ngFor="let permission of permissions" [value]="permission.permission_id">{{permission.permissin_desc}}</option>
    </select>
  </div>
</form>

my ts code:

  'sp_id': this.fb.array([]),

  this.role.permissions.forEach(x => {
              (<FormArray>this.editRoleForm.get('sp_id')).push(new FormControl(x.permission_id)) 
             });

Can you suggest me what is the problem please?

I want to show like this example: enter image description here

Thank you!

13
  • Seems you have already got the answer. Please don't duplicate questions Commented Feb 15, 2018 at 9:55
  • The problem here is that you're using FormArray control on select. But you can't Commented Feb 15, 2018 at 9:57
  • Can you suggest something ex? Commented Feb 15, 2018 at 9:57
  • Which data do you want to post to the server? Commented Feb 15, 2018 at 9:59
  • 1
    plnkr.co/edit/FpiBmGHixTBFPURnu3Ek?p=preview Commented Feb 15, 2018 at 10:58

0

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.