Skip to content

Commit

Permalink
fix(autosize): export md-autosize directive
Browse files Browse the repository at this point in the history
  • Loading branch information
devversion committed Dec 27, 2016
1 parent 026c70a commit 8f22599
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 3 deletions.
16 changes: 13 additions & 3 deletions src/lib/input/autosize.spec.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {Component} from '@angular/core';
import {Component, ViewChild} from '@angular/core';
import {ComponentFixture, TestBed, async} from '@angular/core/testing';
import {By} from '@angular/platform-browser';
import {MdInputModule} from './input';
Expand Down Expand Up @@ -97,6 +97,12 @@ describe('MdTextareaAutosize', () => {
expect(parseInt(textarea.style.maxHeight))
.toBeGreaterThan(previousMaxHeight, 'Expected increased max-height with maxRows increase.');
});

it('should export the mdAutosize reference', () => {
expect(fixture.componentInstance.autosize).toBeTruthy();
expect(fixture.componentInstance.autosize.resizeToFitContent).toBeTruthy();
});

});


Expand All @@ -109,10 +115,14 @@ const textareaStyleReset = `
}`;

@Component({
template: `<textarea md-autosize [minRows]="minRows" [maxRows]="maxRows">{{content}}</textarea>`,
template: `
<textarea md-autosize [minRows]="minRows" [maxRows]="maxRows" #autosize="mdAutosize">
{{content}}
</textarea>`,
styles: [textareaStyleReset],
})
class AutosizeTextAreaWithContent {
@ViewChild('autosize') autosize: MdTextareaAutosize;
minRows: number = null;
maxRows: number = null;
content: string = '';
Expand All @@ -124,4 +134,4 @@ class AutosizeTextAreaWithContent {
})
class AutosizeTextAreaWithValue {
value: string = '';
}
}
1 change: 1 addition & 0 deletions src/lib/input/autosize.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import {Directive, ElementRef, Input, OnInit} from '@angular/core';
*/
@Directive({
selector: 'textarea[md-autosize], textarea[mat-autosize]',
exportAs: 'mdAutosize',
host: {
'(input)': 'resizeToFitContent()',
'[style.min-height]': '_minHeight',
Expand Down

0 comments on commit 8f22599

Please sign in to comment.