Skip to content

Commit ef4bd7d

Browse files
committed
🚧 feat: criou o componente de inserir novo trecho
1 parent f2bb72b commit ef4bd7d

File tree

5 files changed

+33
-7
lines changed

5 files changed

+33
-7
lines changed

src/app/app.module.ts

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
import { BrowserModule } from '@angular/platform-browser';
22
import { NgModule } from '@angular/core';
3-
import { FormsModule } from '@angular/forms';
3+
// import { FormsModule } from '@angular/forms';
44

55
import { AppRoutingModule } from './app-routing.module';
66

77
import {MatCardModule} from '@angular/material/card';
8+
import {MatFormFieldModule} from '@angular/material/form-field';
89

910

1011
import { AppComponent } from './app.component';
@@ -17,6 +18,7 @@ import { LoggingService } from './logging.service';
1718
import { SnippetsComponent } from './components/snippets/snippets.component';
1819
import { SnippetComponent } from './components/snippet/snippet.component';
1920
import { NewSnippetComponent } from './components/new-snippet/new-snippet.component';
21+
import { ReactiveFormsModule } from '@angular/forms';
2022

2123
@NgModule({
2224
declarations: [
@@ -29,9 +31,11 @@ import { NewSnippetComponent } from './components/new-snippet/new-snippet.compon
2931
],
3032
imports: [
3133
BrowserModule,
32-
FormsModule,
34+
// FormsModule,
3335
AppRoutingModule,
34-
MatCardModule
36+
MatCardModule,
37+
MatFormFieldModule,
38+
ReactiveFormsModule
3539

3640
],
3741
providers: [AccountService, LoggingService],
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
textarea {
2+
width: 30%;
3+
height: 6vw;
4+
border: none;
5+
outline: none;
6+
border-radius: 15px;
7+
padding: 20px;
8+
cursor: pointer;
9+
}
Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,4 @@
1-
<p>new-snippet works!</p>
1+
2+
<textarea rows="4">
3+
4+
</textarea>
Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,25 @@
11
import { Component, OnInit } from '@angular/core';
2-
2+
import {FormControl, Validators} from '@angular/forms';
33
@Component({
44
selector: 'app-new-snippet',
55
templateUrl: './new-snippet.component.html',
6-
styleUrls: ['./new-snippet.component.css']
6+
styleUrls: ['./new-snippet.component.css'],
7+
78
})
89
export class NewSnippetComponent implements OnInit {
910

11+
email = new FormControl('', [Validators.required, Validators.email]);
12+
1013
constructor() { }
1114

1215
ngOnInit(): void {
1316
}
1417

18+
getErrorMessage() {
19+
if (this.email.hasError('required')) {
20+
return 'You must enter a value';
21+
}
22+
23+
return this.email.hasError('email') ? 'Not a valid email' : '';
24+
}
1525
}
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<mat-card class="container">
22
<mat-card-content>
3-
3+
<app-new-snippet></app-new-snippet>
44
</mat-card-content>
55
</mat-card>

0 commit comments

Comments
 (0)