angular-ngselect

Angular 2 form status is always invalid with custom validation for ng-select control

自作多情 提交于 2019-12-12 13:07:52
问题 I have used validation in user info form as below. this.userInfoForm = this.fb.group({ retrieveId: [''], customerName: [[],[UtilityService.checkMinLength(3, 50)]], }); I have created below service to check validation @Injectable() export class UtilityService { static checkMinLength(min: number, max: number): ValidatorFn { return (c: AbstractControl) => { if (c.value && c.value != undefined) { return { 'checkMinLength': c.value.some((a) => { if (a.itemName.length < min || a.itemName.length >

How to clear ng-select selection

北战南征 提交于 2019-12-11 16:06:07
问题 Is it possible to programmatically clear the selection of an ng-select dropdown? I'm wanting the equivalent behaviour of clicking the clear icon, but triggered programmatically. I was expecting a clear() method or something similar, but the documented API doesn't have anything along those lines. This is my dropdown code: <ng-select class="ng-select-wrap" [searchFn]="multiTermSearch" [items]="calculationOptions" placeholder="Please select..." name="calculation" #calculationValue="ngModel" [

Angular ng select required option

☆樱花仙子☆ 提交于 2019-12-11 01:13:40
问题 I cannot find out how to use the required option in ng-select. I have tried this: <ng-select #skills required [ngClass]="{ 'is-invalid': f.submitted && skills.invalid }" [items]="options" bindLabel="label" bindValue="value" [multiple]="true" placeholder="Select Skills" [(ngModel)]="registerUserData.skills" name="skills[]"> </ng-select> <div *ngIf="f.submitted && skills.invalid" class="invalid-feedback"> <div *ngIf="skills.errors.required"> Skills are required </div> </div> but no luck there..

How can implement grouping in ng-select of Angular2?

无人久伴 提交于 2019-12-10 18:57:09
问题 I am implementing multiple select dropdown in my Angular2 project by following this link. But now i have to show grouping in this multiple select dropdown so how can i implement this? Or is there any other plugin or something like that i can follow. Component Html: <form [formGroup]="form" class="selector-form"> <div class="marTop20"> <ng-select [options]="options1" [multiple]="multiple1" placeholder="Select multiple" formControlName="selectMultiple" (opened)="onMultipleOpened()" (closed)=

How to add “select all” functionality to ng-select in Angular 5

时间秒杀一切 提交于 2019-12-07 22:39:09
问题 I found an examle which can do "select all": https://ng-select.github.io/ng-select#/multiselect-checkbox But, I get an error: Cannot read property 'selected' of undefined. I am wondering why I got this error, and how to implement "select all" using ng-select in Angular 5. Thank you 回答1: Using ng-select in Angular 5 limits you to using v1.6.3 of ng-select (or < v2.x), but you can accomplish this using the ng-select header template. I included the code below, but this is a working Stackblitz I

set selected value in angular5 ng-select programmaticaly

為{幸葍}努か 提交于 2019-12-02 02:49:46
I'm using angular5 ng-select component: https://github.com/ng-select/ng-select and try to set the selected value (programatically) when the container component first loaded (kind of default selected value set in the model). I didn't find any relevant attribute for it or for the isSelected for each item. Here is my code (filtered): HTML: <ng-select [items]="filter.values" bindLabel="text" bindValue="id" class="input-md" [(ngModel)]="filter.selectedValue"></ng-select> Model: export class FilterData { Name : string; FormattedName : string; values : Filter[]; selectedValue : Filter = null;