Building a web application with Spring Boot and Angular (#6496)
* Initial Commit * Delete angularclient folder * Add spring-boot-angular module to root pom.xml * Update pom.xml * Update root pom.xml * Update root pom.xml
This commit is contained in:
committed by
KevinGilmore
parent
6cd8c51b4d
commit
b10782f89e
@@ -0,0 +1,19 @@
|
||||
<div class="card my-5">
|
||||
<div class="card-body">
|
||||
<form (ngSubmit)="onSubmit()" #userForm="ngForm">
|
||||
<div class="form-group">
|
||||
<label for="name">Name</label>
|
||||
<input type="text" [(ngModel)]="user.name" class="form-control" id="name" name="name" placeholder="Enter your name"
|
||||
required #name="ngModel">
|
||||
</div>
|
||||
<div [hidden]="!name.pristine" class="alert alert-danger">Name is required</div>
|
||||
<div class="form-group">
|
||||
<label for="email">Email</label>
|
||||
<input type="text" [(ngModel)]="user.email" class="form-control" id="email" name="email" placeholder="Enter your email address"
|
||||
required #email="ngModel">
|
||||
<div [hidden]="!email.pristine" class="alert alert-danger">Email is required</div>
|
||||
</div>
|
||||
<button type="submit" [disabled]="!userForm.form.valid" class="btn btn-info">Submit</button>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
@@ -0,0 +1,25 @@
|
||||
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
|
||||
|
||||
import { UserFormComponent } from './user-form.component';
|
||||
|
||||
describe('UserFormComponent', () => {
|
||||
let component: UserFormComponent;
|
||||
let fixture: ComponentFixture<UserFormComponent>;
|
||||
|
||||
beforeEach(async(() => {
|
||||
TestBed.configureTestingModule({
|
||||
declarations: [ UserFormComponent ]
|
||||
})
|
||||
.compileComponents();
|
||||
}));
|
||||
|
||||
beforeEach(() => {
|
||||
fixture = TestBed.createComponent(UserFormComponent);
|
||||
component = fixture.componentInstance;
|
||||
fixture.detectChanges();
|
||||
});
|
||||
|
||||
it('should create', () => {
|
||||
expect(component).toBeTruthy();
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,26 @@
|
||||
import { Component } from '@angular/core';
|
||||
import { ActivatedRoute, Router } from '@angular/router';
|
||||
import { UserService } from '../service/user.service';
|
||||
import { User } from '../model/user';
|
||||
|
||||
@Component({
|
||||
selector: 'app-user-form',
|
||||
templateUrl: './user-form.component.html',
|
||||
styleUrls: ['./user-form.component.css']
|
||||
})
|
||||
export class UserFormComponent {
|
||||
|
||||
user: User;
|
||||
|
||||
constructor(private route: ActivatedRoute, private router: Router, private userService: UserService) {
|
||||
this.user = new User();
|
||||
}
|
||||
|
||||
onSubmit() {
|
||||
this.userService.save(this.user).subscribe(result => this.gotoUserList());
|
||||
}
|
||||
|
||||
gotoUserList() {
|
||||
this.router.navigate(['/users']);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user