Skip to content

Commit 563c2da

Browse files
committed
fix(chips): unable to bind to chip input placeholder
Fixes the value that is bound to the `placeholder` input not being assigned to the `placeholder` attribute. Fixes #10848.
1 parent c61cd69 commit 563c2da

File tree

2 files changed

+13
-2
lines changed

2 files changed

+13
-2
lines changed

src/lib/chips/chip-input.spec.ts

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ describe('MatChipInput', () => {
1616
let inputDebugElement: DebugElement;
1717
let inputNativeElement: HTMLElement;
1818
let chipInputDirective: MatChipInput;
19-
2019
let dir = 'ltr';
2120

2221
beforeEach(async(() => {
@@ -56,6 +55,15 @@ describe('MatChipInput', () => {
5655
it('should have a default id', () => {
5756
expect(inputNativeElement.getAttribute('id')).toBeTruthy();
5857
});
58+
59+
it('should allow binding to the `placeholder` input', () => {
60+
expect(inputNativeElement.hasAttribute('placeholder')).toBe(false);
61+
62+
testChipInput.placeholder = 'bound placeholder';
63+
fixture.detectChanges();
64+
65+
expect(inputNativeElement.getAttribute('placeholder')).toBe('bound placeholder');
66+
});
5967
});
6068

6169
describe('[addOnBlur]', () => {
@@ -142,11 +150,13 @@ describe('MatChipInput', () => {
142150
</mat-chip-list>
143151
<input matInput [matChipInputFor]="chipList"
144152
[matChipInputAddOnBlur]="addOnBlur"
145-
(matChipInputTokenEnd)="add($event)" />
153+
(matChipInputTokenEnd)="add($event)"
154+
[placeholder]="placeholder" />
146155
`
147156
})
148157
class TestChipInput {
149158
addOnBlur: boolean = false;
159+
placeholder = '';
150160

151161
add(_: MatChipInputEvent) {
152162
}

src/lib/chips/chip-input.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ let nextUniqueId = 0;
3838
'(focus)': '_focus()',
3939
'(input)': '_onInput()',
4040
'[id]': 'id',
41+
'[attr.placeholder]': 'placeholder || null',
4142
}
4243
})
4344
export class MatChipInput {

0 commit comments

Comments
 (0)