Last active
May 21, 2018 12:28
-
-
Save realtomaszkula/3f0aaaa0f0a2b8c36e3cad67da6633f4 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
| import { Component } from '@angular/core'; | |
| type Label<T extends object> = { [key in keyof T]: string }; | |
| type PartialLabel<T extends object> = { [key in keyof Partial<T>]: string }; | |
| interface LoginForm { | |
| username: string; | |
| password: string; | |
| } | |
| @Component({ | |
| selector: 'app-form', | |
| template: ` | |
| <form> | |
| <input [(ngModel)]="login.username" name="username" [placeholder]="placeholders.username" /> | |
| <input [(ngModel)]="login.password" name="password" [placeholder]="placeholders.password" /> | |
| <div> {{ hints.password }} </div> | |
| </form> | |
| ` | |
| }) | |
| export class FormComponent { | |
| login: LoginForm = { | |
| username: '', | |
| password: '' | |
| }; | |
| placeholders: Label<LoginForm> = { | |
| username: 'Username', | |
| password: 'Password' | |
| }; | |
| hints: PartialLabel<LoginForm> = { | |
| password: 'Must contain at least one special character' | |
| }; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment