work list
continuous-integration/drone/push Build is passing
Details
continuous-integration/drone/push Build is passing
Details
parent
8518c75b36
commit
1f607b9c2b
@ -0,0 +1,21 @@
|
||||
<h2>Works</h2>
|
||||
|
||||
<ul>
|
||||
<li *ngFor="let work of works">
|
||||
{{ work.id_work }} - {{ work.link }} - {{ work.content }}
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
<form #addBookForm="ngForm" (ngSubmit)="onSubmit(addBookForm)">
|
||||
<div class="form-group">
|
||||
<label for="link">Link</label>
|
||||
<input type="text" class="form-control" id="link" name="link" ngModel required>
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<label for="content">Content</label>
|
||||
<input type="text" class="form-control" id="content" name="content" ngModel required>
|
||||
</div>
|
||||
|
||||
<button type="submit" class="btn btn-primary">Submit</button>
|
||||
</form>
|
@ -0,0 +1,23 @@
|
||||
import { ComponentFixture, TestBed } from '@angular/core/testing';
|
||||
|
||||
import { WorksListComponent } from './works-list.component';
|
||||
|
||||
describe('WorksListComponent', () => {
|
||||
let component: WorksListComponent;
|
||||
let fixture: ComponentFixture<WorksListComponent>;
|
||||
|
||||
beforeEach(async () => {
|
||||
await TestBed.configureTestingModule({
|
||||
imports: [WorksListComponent]
|
||||
})
|
||||
.compileComponents();
|
||||
|
||||
fixture = TestBed.createComponent(WorksListComponent);
|
||||
component = fixture.componentInstance;
|
||||
fixture.detectChanges();
|
||||
});
|
||||
|
||||
it('should create', () => {
|
||||
expect(component).toBeTruthy();
|
||||
});
|
||||
});
|
@ -0,0 +1,30 @@
|
||||
import {Component} from '@angular/core';
|
||||
import {Work} from "../../models/work.model";
|
||||
import {WorkService} from "../../services/work.service";
|
||||
import {NgForOf} from "@angular/common";
|
||||
import {FormsModule, NgForm} from "@angular/forms";
|
||||
|
||||
@Component({
|
||||
selector: 'app-works-list',
|
||||
standalone: true,
|
||||
imports: [
|
||||
NgForOf,
|
||||
FormsModule
|
||||
],
|
||||
templateUrl: './works-list.component.html',
|
||||
styleUrl: './works-list.component.css'
|
||||
})
|
||||
export class WorksListComponent {
|
||||
works: Work[] = [];
|
||||
|
||||
constructor(protected workService: WorkService) {
|
||||
}
|
||||
|
||||
ngOnInit() {
|
||||
this.workService.getWorks().subscribe((response: Work[]) => this.works = response)
|
||||
}
|
||||
|
||||
onSubmit(form: NgForm) {
|
||||
this.workService.postWork(form);
|
||||
}
|
||||
}
|
Loading…
Reference in new issue