-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Rodolfo
committed
Dec 22, 2024
1 parent
ea6989b
commit 5d0d4e4
Showing
12 changed files
with
175 additions
and
488 deletions.
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
{ | ||
"alunos": [ | ||
{ | ||
"id": "1", | ||
"nome": "Rodolfo", | ||
"idade": 30 | ||
} | ||
] | ||
} |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -100,5 +100,8 @@ | |
} | ||
} | ||
} | ||
}, | ||
"cli": { | ||
"analytics": "061cf1f4-62ee-4b87-9563-6f86351bd246" | ||
} | ||
} |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
<h1>Cadastro de Alunos</h1> | ||
<hr> | ||
<form> | ||
<p>Nome: <input type="text" name="name" [(ngModel)]="aluno.nome"></p> | ||
<p>Idade: <input type="text" name="idade" [(ngModel)]="aluno.idade"></p> | ||
<button type="button" (click)="cadastrar()">Cadastrar</button> | ||
</form> | ||
|
||
<hr> | ||
<h1>Alunos Cadastrados</h1> | ||
<table> | ||
<tr> | ||
<th>Nome</th> | ||
<th>Idade</th> | ||
<th>Ações</th> | ||
</tr> | ||
|
||
<tr *ngFor="let aluno of alunos"> | ||
<td>{{aluno.nome }}</td> | ||
<td>{{aluno.idade}}</td> | ||
<td><button (click)="atualizar(aluno.id)">Atulizar</button></td> | ||
<td><button (click)="remover(aluno.id)">Remover</button></td> | ||
|
||
</tr> | ||
</table> | ||
|
Empty file.
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import { ComponentFixture, TestBed } from '@angular/core/testing'; | ||
|
||
import { AlunosComponent } from './alunos.component'; | ||
|
||
describe('AlunosComponent', () => { | ||
let component: AlunosComponent; | ||
let fixture: ComponentFixture<AlunosComponent>; | ||
|
||
beforeEach(async () => { | ||
await TestBed.configureTestingModule({ | ||
declarations: [ AlunosComponent ] | ||
}) | ||
.compileComponents(); | ||
|
||
fixture = TestBed.createComponent(AlunosComponent); | ||
component = fixture.componentInstance; | ||
fixture.detectChanges(); | ||
}); | ||
|
||
it('should create', () => { | ||
expect(component).toBeTruthy(); | ||
}); | ||
}); |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
import { Observable } from 'rxjs'; | ||
import { AlunoModel } from '../model/aluno.model'; | ||
import { AlunosService } from './../service/alunos.service'; | ||
import { Component, OnInit } from '@angular/core'; | ||
|
||
@Component({ | ||
selector: 'app-alunos', | ||
templateUrl: './alunos.component.html', | ||
styleUrls: ['./alunos.component.scss'], | ||
}) | ||
export class AlunosComponent implements OnInit { | ||
aluno: AlunoModel = new AlunoModel(); | ||
|
||
alunos: Array<any> = new Array(); | ||
|
||
constructor(private alunosService: AlunosService) {} | ||
|
||
ngOnInit(): void { | ||
this.listaAlunos(); | ||
} | ||
|
||
cadastrar() { | ||
this.alunosService.cadastroAluno(this.aluno).subscribe((aluno) => { | ||
this.aluno = new AlunoModel(); | ||
this.listaAlunos(); | ||
}); | ||
} | ||
|
||
atualizar(id: string) { | ||
this.alunosService.atualizar(id, this.aluno).subscribe((aluno) => { | ||
this.aluno = new AlunoModel(); | ||
this.listaAlunos(); | ||
}); | ||
} | ||
|
||
remover(id: string) { | ||
this.alunosService.remover(id).subscribe((aluno) => { | ||
this.listaAlunos() | ||
}) | ||
} | ||
|
||
listaAlunos() { | ||
this.alunosService.listaAlunos().subscribe( | ||
(alunos) => { | ||
this.alunos = alunos; | ||
}, | ||
(err) => { | ||
console.log('Erro ao chamar o endpoint', err); | ||
} | ||
); | ||
} | ||
} |
This file contains 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
Oops, something went wrong.