demo commit
This commit is contained in:
+9
@@ -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>
|
||||
|
||||
+13
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
+11
@@ -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';
|
||||
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user