Skip to content

Commit 24cdad7

Browse files
committed
fix(autosize): export md-autosize directive
Closes #2419
1 parent 026c70a commit 24cdad7

File tree

2 files changed

+13
-2
lines changed

2 files changed

+13
-2
lines changed

src/lib/input/autosize.spec.ts

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import {Component} from '@angular/core';
1+
import {Component, ViewChild} from '@angular/core';
22
import {ComponentFixture, TestBed, async} from '@angular/core/testing';
33
import {By} from '@angular/platform-browser';
44
import {MdInputModule} from './input';
@@ -97,6 +97,12 @@ describe('MdTextareaAutosize', () => {
9797
expect(parseInt(textarea.style.maxHeight))
9898
.toBeGreaterThan(previousMaxHeight, 'Expected increased max-height with maxRows increase.');
9999
});
100+
101+
it('should export the mdAutosize reference', () => {
102+
expect(fixture.componentInstance.autosize).toBeTruthy();
103+
expect(fixture.componentInstance.autosize.resizeToFitContent).toBeTruthy();
104+
});
105+
100106
});
101107

102108

@@ -109,10 +115,14 @@ const textareaStyleReset = `
109115
}`;
110116

111117
@Component({
112-
template: `<textarea md-autosize [minRows]="minRows" [maxRows]="maxRows">{{content}}</textarea>`,
118+
template: `
119+
<textarea md-autosize [minRows]="minRows" [maxRows]="maxRows" #autosize="mdAutosize">
120+
{{content}}
121+
</textarea>`,
113122
styles: [textareaStyleReset],
114123
})
115124
class AutosizeTextAreaWithContent {
125+
@ViewChild('autosize') autosize: MdTextareaAutosize;
116126
minRows: number = null;
117127
maxRows: number = null;
118128
content: string = '';

src/lib/input/autosize.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import {Directive, ElementRef, Input, OnInit} from '@angular/core';
66
*/
77
@Directive({
88
selector: 'textarea[md-autosize], textarea[mat-autosize]',
9+
exportAs: 'mdAutosize',
910
host: {
1011
'(input)': 'resizeToFitContent()',
1112
'[style.min-height]': '_minHeight',

0 commit comments

Comments
 (0)