-
Notifications
You must be signed in to change notification settings - Fork 6.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(md-input): add back placeholder as a portal directive
- Loading branch information
Showing
11 changed files
with
227 additions
and
38 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,27 @@ | ||
import {CommonModule} from '@angular/common'; | ||
import {ModuleWithProviders, NgModule} from '@angular/core'; | ||
|
||
import {ProjectionModule, PortalModule} from '../core'; | ||
|
||
import {MdInput} from './input'; | ||
import {MdPlaceholder, MdPlaceholderContent} from './placeholder'; | ||
|
||
|
||
export * from './input'; | ||
export * from './placeholder'; | ||
|
||
|
||
@NgModule({ | ||
declarations: [MdPlaceholderContent, MdPlaceholder, MdInput], | ||
imports: [PortalModule, ProjectionModule, CommonModule], | ||
exports: [MdPlaceholder, MdInput], | ||
entryComponents: [MdPlaceholderContent] | ||
}) | ||
export class MdInputModule { | ||
static forRoot(): ModuleWithProviders { | ||
return { | ||
ngModule: MdInputModule, | ||
providers: [] | ||
}; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
<label class="md-placeholder" | ||
[attr.for]="placeholder?.inputId" | ||
[class.md-empty]="placeholder?.empty" | ||
[class.md-focused]="placeholder?._focused" | ||
[class.md-float]="placeholder?._floatingPlaceholder" | ||
[class.md-accent]="placeholder?.dividerColor == 'accent'" | ||
[class.md-warn]="placeholder?.dividerColor == 'warn'"> | ||
<template [ngTemplateOutlet]="_template()"></template> | ||
<span class="md-placeholder-required" *ngIf="placeholder?._required">*</span> | ||
</label> | ||
|
||
<template #stringTemplate>{{content}}</template> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
import { | ||
async, | ||
TestBed, | ||
} from '@angular/core/testing'; | ||
import {Component} from '@angular/core'; | ||
import {FormsModule} from '@angular/forms'; | ||
import {By} from '@angular/platform-browser'; | ||
import {MdInput, MdInputModule} from './index'; | ||
import {ProjectionModule} from '../core/projection/projection'; | ||
|
||
fdescribe('MdPlaceholder', function () { | ||
beforeEach(async(() => { | ||
TestBed.configureTestingModule({ | ||
imports: [MdInputModule.forRoot(), FormsModule, ProjectionModule.forRoot()], | ||
declarations: [ | ||
MdPlaceholderStringTestController, | ||
MdPlaceholderTemplateTestController, | ||
], | ||
}); | ||
|
||
TestBed.compileComponents(); | ||
})); | ||
|
||
it('works with string placeholder', () => { | ||
let fixture = TestBed.createComponent(MdPlaceholderStringTestController); | ||
fixture.detectChanges(); | ||
let el: HTMLElement = fixture.nativeElement; | ||
console.log(el.innerHTML); | ||
}); | ||
}); | ||
|
||
@Component({template: `<input md-input placeholder="string placeholder">`}) | ||
class MdPlaceholderStringTestController { } | ||
|
||
@Component({template: ` | ||
<input md-input [placeholder]="p"> | ||
<template #p>template placeholder</template> | ||
`}) | ||
class MdPlaceholderTemplateTestController { } |
Oops, something went wrong.