demo commit

This commit is contained in:
Yubing325
2020-07-07 16:36:18 -05:00
parent f4cec5c48f
commit bc4bd55efc
27 changed files with 181 additions and 135 deletions
@@ -23,5 +23,14 @@
index: index
}"></ng-container>
</ng-template>
</ng-container>
<ng-container *ngIf="hasNotFoundTemplate">
<ng-template ng-notfound-tmp let-searchTerm="searchTerm">
<ng-container [ngTemplateOutlet]="selectNotFoundTemplate"
[ngTemplateOutletContext]="{
$implicit: searchTerm
}"></ng-container>
</ng-template>
</ng-container>
</ng-select>
@@ -6,6 +6,7 @@ import { map, distinctUntilChanged, debounceTime } from 'rxjs/operators';
import { NgSelectComponent as SelectComponent } from '@ng-select/ng-select';
import { NG_VALUE_ACCESSOR } from '@angular/forms';
import { SelectOptionTemplateDirective } from '../select-option-template.directive';
import { NotFoundTemplateDirective } from '../not-found-template.directive';
@Component({
@@ -22,6 +23,8 @@ export class NgSelectComponent implements OnInit {
@ContentChild(SelectOptionTemplateDirective) optionTemplate: SelectOptionTemplateDirective;
@ContentChild(SelectLabelTemplateDirective) labelTemplate: SelectLabelTemplateDirective;
@ContentChild(NotFoundTemplateDirective) notFoundTemplate: NotFoundTemplateDirective;
@ViewChild(SelectComponent, { static: true }) selectComponent: SelectComponent;
@@ -154,4 +157,14 @@ export class NgSelectComponent implements OnInit {
return this.labelTemplate.template;
return null;
}
get hasNotFoundTemplate() {
return this.notFoundTemplate ? true : false;
}
get selectNotFoundTemplate(){
if(this.notFoundTemplate)
return this.notFoundTemplate.template;
return null;
}
}
@@ -0,0 +1,11 @@
import { Directive, TemplateRef } from '@angular/core';
@Directive({
selector: '[psNgNotFoundTemplate]'
})
export class NotFoundTemplateDirective {
constructor(public template: TemplateRef<any>) { }
}
@@ -6,11 +6,12 @@ import { FormsModule } from '@angular/forms';
import { NgSelectModule } from '@ng-select/ng-select';
import { SelectLabelTemplateDirective } from './select-label-template.directive';
import { SelectOptionTemplateDirective } from './select-option-template.directive';
import { NotFoundTemplateDirective } from './not-found-template.directive';
@NgModule({
declarations: [NgSelectComponent, MultiSelectComponent, SelectLabelTemplateDirective, SelectOptionTemplateDirective],
declarations: [NgSelectComponent, MultiSelectComponent, SelectLabelTemplateDirective, SelectOptionTemplateDirective, NotFoundTemplateDirective],
imports: [
CommonModule,
FormsModule,
@@ -20,7 +21,8 @@ import { SelectOptionTemplateDirective } from './select-option-template.directiv
NgSelectComponent,
MultiSelectComponent,
SelectLabelTemplateDirective,
SelectOptionTemplateDirective
SelectOptionTemplateDirective,
NotFoundTemplateDirective
]
})
export class PsNgSelectorsModule { }
export class PsNgSelectorsModule { }//NGSELECT
@@ -6,7 +6,8 @@ export * from './lib/ps-ng-selectors/ps-ng-selectors.module';
export * from './lib/ps-ng-selectors/ng-select/ng-select.component';
export * from './lib/ps-ng-selectors/multi-select/multi-select.component';
export * from './lib/ps-ng-selectors/select-label-template.directive';
export * from './lib/ps-ng-selectors/select-option-template.directive'
export * from './lib/ps-ng-selectors/select-option-template.directive';
export * from './lib/ps-ng-selectors/not-found-template.directive';