Advertisement
Guest User

Untitled

a guest
Mar 31st, 2020
199
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.28 KB | None | 0 0
  1. Menu
  2. register-menu
  3. update-menu
  4. remove-menu
  5.  
  6. Menu
  7. create-menu
  8. edit-menu
  9. remove-menu
  10.  
  11.  
  12.  
  13.  
  14.  
  15.  
  16. https://stackblitz.com/edit/angular-material-design-pacnbm?
  17.  
  18. file=src/app/withmaterial/withmaterial.component.html
  19.  
  20.  
  21.  
  22.  
  23.  
  24. <mat-toolbar>
  25. Novo Cardápio
  26. </mat-toolbar>
  27.  
  28. <form [formGroup]="menuForm" (ngSubmit)="onSubmit()">
  29. <div class="form-field">
  30. <mat-checkbox color="primary" fxFill formControlName="active">Cardápio ativo</mat-checkbox>
  31. </div>
  32. <div class="form-field">
  33. <mat-form-field appearance="outline" fxFlex.xs="100" fxFlex.sm="80" fxFlex.md="60"
  34.  
  35. fxFlex.lg="40" fxFlex.xl="20">
  36. <mat-label>Nome do cardápio</mat-label>
  37. <input matInput #name maxlength="150" placeholder="Cardápio exemplo"
  38.  
  39. formControlName="name" />
  40. <mat-hint align="end">{{name.value?.length || 0}}/150</mat-hint>
  41. </mat-form-field>
  42. </div>
  43. <div class="form-field">
  44. <mat-form-field appearance="outline" fxFlex.xs="100" fxFlex.sm="80" fxFlex.md="60"
  45. fxFlex.lg="40" fxFlex.xl="20">
  46. <mat-label>Descrição do cardápio</mat-label>
  47. <textarea matInput #description maxlength="500" rows="3"
  48. placeholder="Cardápio promocional do fim de semana, cardápio padrão do local, etc."
  49.  
  50. formControlName="description"></textarea>
  51. <mat-hint align="end">{{description.value?.length || 0}}/500</mat-hint>
  52. </mat-form-field>
  53. </div>
  54. <div class="form-field">
  55. <button mat-raised-button color="primary" type="submit">
  56. <mat-icon>done</mat-icon>
  57. Confirmar
  58. </button>
  59. </div>
  60. </form>
  61.  
  62.  
  63.  
  64.  
  65.  
  66.  
  67.  
  68. mat-toolbar {
  69. margin-bottom: 50px;
  70. }
  71.  
  72. mat-icon {
  73. margin-right: 10px;
  74. }
  75.  
  76. .form-field {
  77. margin: 15px 0 15px 0;
  78. }
  79.  
  80.  
  81.  
  82.  
  83. import {Component} from '@angular/core';
  84. import {FormGroup, FormBuilder, FormControl, Validators} from '@angular/forms';
  85. /** @title Simple form field */
  86. @Component({
  87. selector: 'form-field-overview-example',
  88. templateUrl: 'form-field-overview-example.html',
  89. styleUrls: ['form-field-overview-example.css'],
  90. })
  91. export class FormFieldOverviewExample {
  92. constructor(private formBuilder: FormBuilder){
  93. }
  94.  
  95. menuForm = this.formBuilder.group({
  96. active: [true],
  97. name: ['', Validators.required, Validators.maxLength(150)],
  98. description: [''],
  99. });
  100.  
  101. onSubmit(){
  102. console.log(this.menuForm.value)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement