valor-software / ng2-select

Angular based replacement for select boxes
http://valor-software.github.io/ng2-select/
MIT License
675 stars 587 forks source link

Adds functionality to make ng2-select compatible with form-controls #881

Closed sonukapoor closed 6 years ago

sonukapoor commented 7 years ago

Please review attached PR. It allows you to use the ng2-select component with ngModel.

Simple usage:

Add the following attributes:

name is the name of your control. [(ngModel)] should be set to your selected items. It's should be the same as [active].

`<form #form="ngForm"> <ng-select required name="mySelect"

mySelect="ngModel"

    [(ngModel)]="selectedItems"
    [active]="selectedItems"
    [items]="newItems">
  </ng-select>

`

Is Form Valid: {{ form.valid }}
Is Control Valid: {{ mySelect.valid }}

Note: I have tested this only with template forms.

Feedback is appreciated.

codecov[bot] commented 7 years ago

Codecov Report

Merging #881 into development will decrease coverage by 6.95%. The diff coverage is 55.81%.

Impacted file tree graph

@@               Coverage Diff               @@
##           development     #881      +/-   ##
===============================================
- Coverage        37.33%   30.37%   -6.96%     
===============================================
  Files               11       11              
  Lines              450      451       +1     
  Branches            73       76       +3     
===============================================
- Hits               168      137      -31     
- Misses             282      313      +31     
- Partials             0        1       +1
Impacted Files Coverage Δ
src/select/select.ts 19.04% <55.81%> (-8.67%) :arrow_down:
src/select/select-pipes.ts 31.57% <0%> (-3.43%) :arrow_down:
src/select/off-click.ts 70% <0%> (-2.73%) :arrow_down:
src/select/select.module.ts 100% <0%> (ø) :arrow_up:

Continue to review full report at Codecov.

Legend - Click here to learn more Δ = absolute <relative> (impact), ø = not affected, ? = missing data Powered by Codecov. Last update 3afaf63...d76c726. Read the comment docs.

sonukapoor commented 7 years ago

@valorkin Any chance to get this merged?

eamonn commented 6 years ago

@sonukapoor good work. Any chance you can merge this @valorkin ???

valorkin commented 6 years ago

thanks for contributing! please remove package-lock

I am addressing this PR to ngx team, we will try to publish it soon

sonukapoor commented 6 years ago

Will do. On Wed, Oct 25, 2017 at 8:01 AM Dmitriy Shekhovtsov < notifications@github.com> wrote:

thanks for contributing! please remove package-lock

I am addressing this PR to ngx team, we will try to publish it soon

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/valor-software/ng2-select/pull/881#issuecomment-339307098, or mute the thread https://github.com/notifications/unsubscribe-auth/AADpVrw8RhRGNfVs7UZLD2dOtNeI_N-kks5svyMTgaJpZM4POtb3 .

sonukapoor commented 6 years ago

@valorkin done. I also reverted the other files. Please also note that my vs code formatted the file with proper spaces etc. and when reviewing you should ignore the white spaces:

https://github.com/valor-software/ng2-select/pull/881/files?w=1

mohamedfathii commented 6 years ago

when this PR will be merged ?

sonukapoor commented 6 years ago

I have a separate fork with the compiled version of the ng2-select using this PR that is available for anybody that wants to use it:

https://github.com/sonukapoor/ng2-select-forms

IlyaSurmay commented 6 years ago

I'm updating dependencies right now so we'll be able to test it soon, then it will be merged.