Skip to content

Commit c8327d7

Browse files
author
Tom
committed
feat: add placeholder property to support custom placeholders
1 parent 964942d commit c8327d7

File tree

3 files changed

+4
-3
lines changed

3 files changed

+4
-3
lines changed

src/app/app.component.html

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,6 @@ <h1>Test Page</h1>
66

77
<h1>Reactive form Test Page</h1>
88
<div style="position: absolute; top: 60%; left: 50%; height: 50px; width: 50%;">
9-
<mat-search-bar [formControl]="control"></mat-search-bar>
9+
<mat-search-bar [formControl]="control" [placeholder]="'custom placeholder'"></mat-search-bar>
1010
<p>{{ control.value }}</p>
1111
</div>

src/app/ng-mat-search-bar/mat-search-bar/mat-search-bar.component.html

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
<mat-form-field *ngIf="!formControl" class="mat-search_field" [@slideInOut]="searchVisible">
2-
<input #input matInput type="text" placeholder="" [(ngModel)]="value" (ngModelChange)="updateChanges()"
2+
<input #input matInput type="text" [placeholder]="placeholder" [(ngModel)]="value" (ngModelChange)="updateChanges()"
33
(blur)="onBlurring(input.value)" (keyup.enter)="onEnterring(input.value)" (focus)="onFocussing(input.value)" />
44
</mat-form-field>
55

66
<!-- FORM CONTROL WAY -->
77
<mat-form-field *ngIf="formControl" class="mat-search_field" [@slideInOut]="searchVisible">
8-
<input #input matInput type="text" placeholder="" [formControl]="formControl" (blur)="onBlurring(input.value)"
8+
<input #input matInput type="text" [placeholder]="placeholder" [formControl]="formControl" (blur)="onBlurring(input.value)"
99
(keyup.enter)="onEnterring(input.value)" (focus)="onFocussing(input.value)" />
1010
</mat-form-field>
1111

src/app/ng-mat-search-bar/mat-search-bar/mat-search-bar.component.ts

+1
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ string
4545
@ViewChild('input', { static: false }) inputElement: ElementRef;
4646

4747
@Input() formControl: FormControl;
48+
@Input() placeholder = '';
4849

4950
@Output() onBlur = new EventEmitter<string>();
5051
@Output() onClose = new EventEmitter<void>();

0 commit comments

Comments
 (0)