Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <form [formGroup]="createForm" class="create-form">
- <mat-form-field class="field-full-width">
- <input matInput placeholder="Tytuł reklamacji" formControlName="tytul" #tytul>
- </mat-form-field>
- <mat-form-field class="field-full-width">
- <input matInput placeholder="Data D.M.RRRR" formControlName="data" #data>
- </mat-form-field>
- <mat-form-field class="field-full-width">
- <textarea matInput placeholder="Opis" formControlName="opis" #opis></textarea>
- </mat-form-field>
- <mat-form-field>
- <mat-select placeholder="Priorytet" formControlName="priorytet" #priorytet>
- <mat-option value="wolny">Wolny</mat-option>
- <mat-option value="normalny">Normalny</mat-option>
- <mat-option value="szybki">Szybki</mat-option>
- </mat-select>
- </mat-form-field>
- <mat-divider></mat-divider>
- <br><br>
- <button mat-raised-button color="accent" routerLink="/userpage">Cofnij</button>
- <button type="submit" (click)="addReklam(tytul.value, data.value, opis.value, priorytet.value)" [disabled]="createForm.pristine || createForm.invalid" mat-raised-button color="primary">Dodaj</button>
- </form>
- -----------------------------------------TS----------------------------------------
- import { Component, OnInit } from '@angular/core';
- import { FormGroup, FormBuilder, Validators } from '@angular/forms';
- import { Router } from '@angular/router';
- import { NewuserService } from 'src/app/newuser.service';
- import { MatSnackBar } from '@angular/material';
- @Component({
- selector: 'app-addreklamacje',
- templateUrl: './addreklamacje.component.html',
- styleUrls: ['./addreklamacje.component.css']
- })
- export class AddreklamacjeComponent implements OnInit {
- createForm: FormGroup;
- constructor(private serwis: NewuserService, private fb: FormBuilder, private router: Router, private snackBar: MatSnackBar ) {
- this.createForm = this.fb.group({
- tytul: ['', Validators.required],
- data: ['', Validators.required],
- opis: ['', Validators.required],
- priorytet: ['', Validators.required]
- });
- }
- addReklam(tytul,data,opis,priorytet)
- {
- this.serwis.addReklam(tytul,data,opis,priorytet,this.serwis.uzytkownik[0]._id).subscribe(() => {
- this.snackBar.open('Reklamacja dodana pomyślnie!','OK', {
- duration: 5000
- });
- this.router.navigate(['/userpage']);
- });
- }
- ngOnInit() {
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement