Guest User

Untitled

a guest
May 25th, 2018
123
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.83 KB | None | 0 0
  1. import { Component } from '@angular/core';
  2.  
  3. type Label<T extends object> = { [key in keyof T]: string };
  4. type PartialLabel<T extends object> = { [key in keyof Partial<T>]: string };
  5.  
  6. interface LoginForm {
  7. username: string;
  8. password: string;
  9. }
  10.  
  11. @Component({
  12. selector: 'app-form',
  13. template: `
  14. <form>
  15. <input [(ngModel)]="login.username" name="username" [placeholder]="placeholders.username" />
  16. <input [(ngModel)]="login.password" name="password" [placeholder]="placeholders.password" />
  17. <div> {{ hints.password }} </div>
  18. </form>
  19. `
  20. })
  21. export class FormComponent {
  22. login: LoginForm = {
  23. username: '',
  24. password: ''
  25. };
  26.  
  27. placeholders: Label<LoginForm> = {
  28. username: 'Username',
  29. password: 'Password'
  30. };
  31.  
  32. hints: PartialLabel<LoginForm> = {
  33. password: 'Must contain at least one special character'
  34. };
  35. }
Add Comment
Please, Sign In to add comment