├── README.md
├── angular-6-springboot-client
├── .angulardoc.json
├── .editorconfig
├── .gitignore
├── README.md
├── angular.json
├── e2e
│ ├── protractor.conf.js
│ ├── src
│ │ ├── app.e2e-spec.ts
│ │ └── app.po.ts
│ └── tsconfig.e2e.json
├── package-lock.json
├── package.json
├── proxy.conf.json
├── src
│ ├── app
│ │ ├── app-routing.module.ts
│ │ ├── app.component.css
│ │ ├── app.component.html
│ │ ├── app.component.spec.ts
│ │ ├── app.component.ts
│ │ ├── app.module.ts
│ │ ├── create-employee
│ │ │ ├── create-employee.component.css
│ │ │ ├── create-employee.component.html
│ │ │ ├── create-employee.component.spec.ts
│ │ │ └── create-employee.component.ts
│ │ ├── employee-details
│ │ │ ├── employee-details.component.css
│ │ │ ├── employee-details.component.html
│ │ │ ├── employee-details.component.spec.ts
│ │ │ └── employee-details.component.ts
│ │ ├── employee-list
│ │ │ ├── employee-list.component.css
│ │ │ ├── employee-list.component.html
│ │ │ ├── employee-list.component.spec.ts
│ │ │ └── employee-list.component.ts
│ │ ├── employee.service.spec.ts
│ │ ├── employee.service.ts
│ │ ├── employee.spec.ts
│ │ └── employee.ts
│ ├── browserslist
│ ├── environments
│ │ ├── environment.prod.ts
│ │ └── environment.ts
│ ├── favicon.ico
│ ├── index.html
│ ├── karma.conf.js
│ ├── main.ts
│ ├── polyfills.ts
│ ├── styles.css
│ ├── test.ts
│ ├── tsconfig.app.json
│ ├── tsconfig.spec.json
│ └── tslint.json
├── tsconfig.json
└── tslint.json
└── springboot2-jpa-crud-example
├── .gitignore
├── .mvn
└── wrapper
│ ├── maven-wrapper.jar
│ └── maven-wrapper.properties
├── mvnw
├── mvnw.cmd
├── pom.xml
└── src
├── main
├── java
│ └── net
│ │ └── guides
│ │ └── springboot2
│ │ └── springboot2jpacrudexample
│ │ ├── Application.java
│ │ ├── controller
│ │ └── EmployeeController.java
│ │ ├── exception
│ │ ├── ErrorDetails.java
│ │ ├── GlobalExceptionHandler.java
│ │ └── ResourceNotFoundException.java
│ │ ├── model
│ │ └── Employee.java
│ │ └── repository
│ │ └── EmployeeRepository.java
└── resources
│ └── application.properties
└── test
└── java
└── net
└── guides
└── springboot2
└── springboot2jpacrudexample
├── ApplicationTests.java
└── EmployeeControllerIntegrationTest.java
/README.md:
--------------------------------------------------------------------------------
1 | # angular6-springboot-crud-tutorial
2 | Angular 6 + Spring Boot 2 + Spring Data JPA + MySQL + CRUD Tutorial
3 |
4 | http://www.javaguides.net/2019/02/spring-boot-angular-6-crud-example.html
5 |
--------------------------------------------------------------------------------
/angular-6-springboot-client/.angulardoc.json:
--------------------------------------------------------------------------------
1 | {
2 | "repoId": "2af7219a-c3eb-48de-9543-b2b58784bdef",
3 | "lastSync": 0
4 | }
--------------------------------------------------------------------------------
/angular-6-springboot-client/.editorconfig:
--------------------------------------------------------------------------------
1 | # Editor configuration, see https://editorconfig.org
2 | root = true
3 |
4 | [*]
5 | charset = utf-8
6 | indent_style = space
7 | indent_size = 2
8 | insert_final_newline = true
9 | trim_trailing_whitespace = true
10 |
11 | [*.md]
12 | max_line_length = off
13 | trim_trailing_whitespace = false
14 |
--------------------------------------------------------------------------------
/angular-6-springboot-client/.gitignore:
--------------------------------------------------------------------------------
1 | # See http://help.github.com/ignore-files/ for more about ignoring files.
2 |
3 | # compiled output
4 | /dist
5 | /tmp
6 | /out-tsc
7 |
8 | # dependencies
9 | /node_modules
10 |
11 | # profiling files
12 | chrome-profiler-events.json
13 | speed-measure-plugin.json
14 |
15 | # IDEs and editors
16 | /.idea
17 | .project
18 | .classpath
19 | .c9/
20 | *.launch
21 | .settings/
22 | *.sublime-workspace
23 |
24 | # IDE - VSCode
25 | .vscode/*
26 | !.vscode/settings.json
27 | !.vscode/tasks.json
28 | !.vscode/launch.json
29 | !.vscode/extensions.json
30 | .history/*
31 |
32 | # misc
33 | /.sass-cache
34 | /connect.lock
35 | /coverage
36 | /libpeerconnection.log
37 | npm-debug.log
38 | yarn-error.log
39 | testem.log
40 | /typings
41 |
42 | # System Files
43 | .DS_Store
44 | Thumbs.db
45 |
--------------------------------------------------------------------------------
/angular-6-springboot-client/README.md:
--------------------------------------------------------------------------------
1 | # Angular6SpringbootClient
2 |
3 | This project was generated with [Angular CLI](https://github.com/angular/angular-cli) version 7.2.1.
4 |
5 | ## Development server
6 |
7 | Run `ng serve` for a dev server. Navigate to `http://localhost:4200/`. The app will automatically reload if you change any of the source files.
8 |
9 | ## Code scaffolding
10 |
11 | Run `ng generate component component-name` to generate a new component. You can also use `ng generate directive|pipe|service|class|guard|interface|enum|module`.
12 |
13 | ## Build
14 |
15 | Run `ng build` to build the project. The build artifacts will be stored in the `dist/` directory. Use the `--prod` flag for a production build.
16 |
17 | ## Running unit tests
18 |
19 | Run `ng test` to execute the unit tests via [Karma](https://karma-runner.github.io).
20 |
21 | ## Running end-to-end tests
22 |
23 | Run `ng e2e` to execute the end-to-end tests via [Protractor](http://www.protractortest.org/).
24 |
25 | ## Further help
26 |
27 | To get more help on the Angular CLI use `ng help` or go check out the [Angular CLI README](https://github.com/angular/angular-cli/blob/master/README.md).
28 |
--------------------------------------------------------------------------------
/angular-6-springboot-client/angular.json:
--------------------------------------------------------------------------------
1 | {
2 | "$schema": "./node_modules/@angular/cli/lib/config/schema.json",
3 | "version": 1,
4 | "newProjectRoot": "projects",
5 | "projects": {
6 | "angular6-springboot-client": {
7 | "root": "",
8 | "sourceRoot": "src",
9 | "projectType": "application",
10 | "prefix": "app",
11 | "schematics": {},
12 | "architect": {
13 | "build": {
14 | "builder": "@angular-devkit/build-angular:browser",
15 | "options": {
16 | "outputPath": "dist/angular6-springboot-client",
17 | "index": "src/index.html",
18 | "main": "src/main.ts",
19 | "polyfills": "src/polyfills.ts",
20 | "tsConfig": "src/tsconfig.app.json",
21 | "assets": [
22 | "src/favicon.ico",
23 | "src/assets"
24 | ],
25 | "styles": [
26 | "src/styles.css",
27 | "node_modules/bootstrap/dist/css/bootstrap.min.css"
28 | ],
29 | "scripts": [
30 | "node_modules/jquery/dist/jquery.min.js",
31 | "node_modules/bootstrap/dist/js/bootstrap.min.js"
32 | ]
33 | },
34 | "configurations": {
35 | "production": {
36 | "fileReplacements": [
37 | {
38 | "replace": "src/environments/environment.ts",
39 | "with": "src/environments/environment.prod.ts"
40 | }
41 | ],
42 | "optimization": true,
43 | "outputHashing": "all",
44 | "sourceMap": false,
45 | "extractCss": true,
46 | "namedChunks": false,
47 | "aot": true,
48 | "extractLicenses": true,
49 | "vendorChunk": false,
50 | "buildOptimizer": true,
51 | "budgets": [
52 | {
53 | "type": "initial",
54 | "maximumWarning": "2mb",
55 | "maximumError": "5mb"
56 | }
57 | ]
58 | }
59 | }
60 | },
61 | "serve": {
62 | "builder": "@angular-devkit/build-angular:dev-server",
63 | "options": {
64 | "browserTarget": "angular6-springboot-client:build"
65 | },
66 | "configurations": {
67 | "production": {
68 | "browserTarget": "angular6-springboot-client:build:production"
69 | }
70 | }
71 | },
72 | "extract-i18n": {
73 | "builder": "@angular-devkit/build-angular:extract-i18n",
74 | "options": {
75 | "browserTarget": "angular6-springboot-client:build"
76 | }
77 | },
78 | "test": {
79 | "builder": "@angular-devkit/build-angular:karma",
80 | "options": {
81 | "main": "src/test.ts",
82 | "polyfills": "src/polyfills.ts",
83 | "tsConfig": "src/tsconfig.spec.json",
84 | "karmaConfig": "src/karma.conf.js",
85 | "styles": [
86 | "src/styles.css"
87 | ],
88 | "scripts": [],
89 | "assets": [
90 | "src/favicon.ico",
91 | "src/assets"
92 | ]
93 | }
94 | },
95 | "lint": {
96 | "builder": "@angular-devkit/build-angular:tslint",
97 | "options": {
98 | "tsConfig": [
99 | "src/tsconfig.app.json",
100 | "src/tsconfig.spec.json"
101 | ],
102 | "exclude": [
103 | "**/node_modules/**"
104 | ]
105 | }
106 | }
107 | }
108 | },
109 | "angular6-springboot-client-e2e": {
110 | "root": "e2e/",
111 | "projectType": "application",
112 | "prefix": "",
113 | "architect": {
114 | "e2e": {
115 | "builder": "@angular-devkit/build-angular:protractor",
116 | "options": {
117 | "protractorConfig": "e2e/protractor.conf.js",
118 | "devServerTarget": "angular6-springboot-client:serve"
119 | },
120 | "configurations": {
121 | "production": {
122 | "devServerTarget": "angular6-springboot-client:serve:production"
123 | }
124 | }
125 | },
126 | "lint": {
127 | "builder": "@angular-devkit/build-angular:tslint",
128 | "options": {
129 | "tsConfig": "e2e/tsconfig.e2e.json",
130 | "exclude": [
131 | "**/node_modules/**"
132 | ]
133 | }
134 | }
135 | }
136 | }
137 | },
138 | "defaultProject": "angular6-springboot-client"
139 | }
140 |
--------------------------------------------------------------------------------
/angular-6-springboot-client/e2e/protractor.conf.js:
--------------------------------------------------------------------------------
1 | // Protractor configuration file, see link for more information
2 | // https://github.com/angular/protractor/blob/master/lib/config.ts
3 |
4 | const { SpecReporter } = require('jasmine-spec-reporter');
5 |
6 | exports.config = {
7 | allScriptsTimeout: 11000,
8 | specs: [
9 | './src/**/*.e2e-spec.ts'
10 | ],
11 | capabilities: {
12 | 'browserName': 'chrome'
13 | },
14 | directConnect: true,
15 | baseUrl: 'http://localhost:4200/',
16 | framework: 'jasmine',
17 | jasmineNodeOpts: {
18 | showColors: true,
19 | defaultTimeoutInterval: 30000,
20 | print: function() {}
21 | },
22 | onPrepare() {
23 | require('ts-node').register({
24 | project: require('path').join(__dirname, './tsconfig.e2e.json')
25 | });
26 | jasmine.getEnv().addReporter(new SpecReporter({ spec: { displayStacktrace: true } }));
27 | }
28 | };
--------------------------------------------------------------------------------
/angular-6-springboot-client/e2e/src/app.e2e-spec.ts:
--------------------------------------------------------------------------------
1 | import { AppPage } from './app.po';
2 |
3 | describe('workspace-project App', () => {
4 | let page: AppPage;
5 |
6 | beforeEach(() => {
7 | page = new AppPage();
8 | });
9 |
10 | it('should display welcome message', () => {
11 | page.navigateTo();
12 | expect(page.getTitleText()).toEqual('Welcome to angular6-springboot-client!');
13 | });
14 | });
15 |
--------------------------------------------------------------------------------
/angular-6-springboot-client/e2e/src/app.po.ts:
--------------------------------------------------------------------------------
1 | import { browser, by, element } from 'protractor';
2 |
3 | export class AppPage {
4 | navigateTo() {
5 | return browser.get('/');
6 | }
7 |
8 | getTitleText() {
9 | return element(by.css('app-root h1')).getText();
10 | }
11 | }
12 |
--------------------------------------------------------------------------------
/angular-6-springboot-client/e2e/tsconfig.e2e.json:
--------------------------------------------------------------------------------
1 | {
2 | "extends": "../tsconfig.json",
3 | "compilerOptions": {
4 | "outDir": "../out-tsc/app",
5 | "module": "commonjs",
6 | "target": "es5",
7 | "types": [
8 | "jasmine",
9 | "jasminewd2",
10 | "node"
11 | ]
12 | }
13 | }
--------------------------------------------------------------------------------
/angular-6-springboot-client/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "angular6-springboot-client",
3 | "version": "0.0.0",
4 | "scripts": {
5 | "ng": "ng",
6 | "start": "ng serve --proxy-config proxy.conf.json",
7 | "build": "ng build",
8 | "test": "ng test",
9 | "lint": "ng lint",
10 | "e2e": "ng e2e"
11 | },
12 | "private": true,
13 | "dependencies": {
14 | "@angular/animations": "~7.2.0",
15 | "@angular/common": "~7.2.0",
16 | "@angular/compiler": "~7.2.0",
17 | "@angular/core": "~7.2.0",
18 | "@angular/forms": "~7.2.0",
19 | "@angular/platform-browser": "~7.2.0",
20 | "@angular/platform-browser-dynamic": "~7.2.0",
21 | "@angular/router": "~7.2.0",
22 | "bootstrap": "^4.2.1",
23 | "core-js": "^2.5.4",
24 | "jquery": "^3.3.1",
25 | "rxjs": "~6.3.3",
26 | "tslib": "^1.9.0",
27 | "zone.js": "~0.8.26"
28 | },
29 | "devDependencies": {
30 | "@angular-devkit/build-angular": "~0.12.0",
31 | "@angular/cli": "~7.2.1",
32 | "@angular/compiler-cli": "~7.2.0",
33 | "@angular/language-service": "~7.2.0",
34 | "@types/node": "~8.9.4",
35 | "@types/jasmine": "~2.8.8",
36 | "@types/jasminewd2": "~2.0.3",
37 | "codelyzer": "~4.5.0",
38 | "jasmine-core": "~2.99.1",
39 | "jasmine-spec-reporter": "~4.2.1",
40 | "karma": "~3.1.1",
41 | "karma-chrome-launcher": "~2.2.0",
42 | "karma-coverage-istanbul-reporter": "~2.0.1",
43 | "karma-jasmine": "~1.1.2",
44 | "karma-jasmine-html-reporter": "^0.2.2",
45 | "protractor": "~5.4.0",
46 | "ts-node": "~7.0.0",
47 | "tslint": "~5.11.0",
48 | "typescript": "~3.2.2"
49 | }
50 | }
51 |
--------------------------------------------------------------------------------
/angular-6-springboot-client/proxy.conf.json:
--------------------------------------------------------------------------------
1 | {
2 | "/api/v1/employees": {
3 | "target": "http://localhost:8080",
4 | "secure": false
5 | }
6 | }
7 |
--------------------------------------------------------------------------------
/angular-6-springboot-client/src/app/app-routing.module.ts:
--------------------------------------------------------------------------------
1 | import { EmployeeDetailsComponent } from './employee-details/employee-details.component';
2 | import { CreateEmployeeComponent } from './create-employee/create-employee.component';
3 | import { NgModule } from '@angular/core';
4 | import { Routes, RouterModule } from '@angular/router';
5 | import { EmployeeListComponent } from './employee-list/employee-list.component';
6 |
7 | const routes: Routes = [
8 | { path: '', redirectTo: 'employee', pathMatch: 'full' },
9 | { path: 'employees', component: EmployeeListComponent },
10 | { path: 'add', component: CreateEmployeeComponent },
11 | ];
12 |
13 | @NgModule({
14 | imports: [RouterModule.forRoot(routes)],
15 | exports: [RouterModule]
16 | })
17 | export class AppRoutingModule { }
18 |
--------------------------------------------------------------------------------
/angular-6-springboot-client/src/app/app.component.css:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RameshMF/angular6-springboot-crud-tutorial/f3f0ec7b0bb973df7237f740d0b4d0876d247cf4/angular-6-springboot-client/src/app/app.component.css
--------------------------------------------------------------------------------
/angular-6-springboot-client/src/app/app.component.html:
--------------------------------------------------------------------------------
1 |
2 |
{{title}}
3 |
4 |
5 |
17 |
18 |
19 |
--------------------------------------------------------------------------------
/angular-6-springboot-client/src/app/app.component.spec.ts:
--------------------------------------------------------------------------------
1 | import { TestBed, async } from '@angular/core/testing';
2 | import { RouterTestingModule } from '@angular/router/testing';
3 | import { AppComponent } from './app.component';
4 |
5 | describe('AppComponent', () => {
6 | beforeEach(async(() => {
7 | TestBed.configureTestingModule({
8 | imports: [
9 | RouterTestingModule
10 | ],
11 | declarations: [
12 | AppComponent
13 | ],
14 | }).compileComponents();
15 | }));
16 |
17 | it('should create the app', () => {
18 | const fixture = TestBed.createComponent(AppComponent);
19 | const app = fixture.debugElement.componentInstance;
20 | expect(app).toBeTruthy();
21 | });
22 |
23 | it(`should have as title 'angular6-springboot-client'`, () => {
24 | const fixture = TestBed.createComponent(AppComponent);
25 | const app = fixture.debugElement.componentInstance;
26 | expect(app.title).toEqual('angular6-springboot-client');
27 | });
28 |
29 | it('should render title in a h1 tag', () => {
30 | const fixture = TestBed.createComponent(AppComponent);
31 | fixture.detectChanges();
32 | const compiled = fixture.debugElement.nativeElement;
33 | expect(compiled.querySelector('h1').textContent).toContain('Welcome to angular6-springboot-client!');
34 | });
35 | });
36 |
--------------------------------------------------------------------------------
/angular-6-springboot-client/src/app/app.component.ts:
--------------------------------------------------------------------------------
1 | import { Component } from '@angular/core';
2 |
3 | @Component({
4 | selector: 'app-root',
5 | templateUrl: './app.component.html',
6 | styleUrls: ['./app.component.css']
7 | })
8 | export class AppComponent {
9 | title = 'Angular 6 + Spring Boot 2 + Spring Data JPA + MySQL + CRUD Tutorial';
10 | }
11 |
--------------------------------------------------------------------------------
/angular-6-springboot-client/src/app/app.module.ts:
--------------------------------------------------------------------------------
1 | import { BrowserModule } from '@angular/platform-browser';
2 | import { NgModule } from '@angular/core';
3 | import { FormsModule } from '@angular/forms';
4 | import { AppRoutingModule } from './app-routing.module';
5 | import { AppComponent } from './app.component';
6 | import { CreateEmployeeComponent } from './create-employee/create-employee.component';
7 | import { EmployeeDetailsComponent } from './employee-details/employee-details.component';
8 | import { EmployeeListComponent } from './employee-list/employee-list.component';
9 | import { HttpClientModule } from '@angular/common/http';
10 | @NgModule({
11 | declarations: [
12 | AppComponent,
13 | CreateEmployeeComponent,
14 | EmployeeDetailsComponent,
15 | EmployeeListComponent
16 | ],
17 | imports: [
18 | BrowserModule,
19 | AppRoutingModule,
20 | FormsModule,
21 | HttpClientModule
22 | ],
23 | providers: [],
24 | bootstrap: [AppComponent]
25 | })
26 | export class AppModule { }
27 |
--------------------------------------------------------------------------------
/angular-6-springboot-client/src/app/create-employee/create-employee.component.css:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RameshMF/angular6-springboot-crud-tutorial/f3f0ec7b0bb973df7237f740d0b4d0876d247cf4/angular-6-springboot-client/src/app/create-employee/create-employee.component.css
--------------------------------------------------------------------------------
/angular-6-springboot-client/src/app/create-employee/create-employee.component.html:
--------------------------------------------------------------------------------
1 | Create Employee
2 |
22 |
23 |
24 |
You submitted successfully!
25 |
26 |
27 |
--------------------------------------------------------------------------------
/angular-6-springboot-client/src/app/create-employee/create-employee.component.spec.ts:
--------------------------------------------------------------------------------
1 | import { async, ComponentFixture, TestBed } from '@angular/core/testing';
2 |
3 | import { CreateEmployeeComponent } from './create-employee.component';
4 |
5 | describe('CreateEmployeeComponent', () => {
6 | let component: CreateEmployeeComponent;
7 | let fixture: ComponentFixture;
8 |
9 | beforeEach(async(() => {
10 | TestBed.configureTestingModule({
11 | declarations: [ CreateEmployeeComponent ]
12 | })
13 | .compileComponents();
14 | }));
15 |
16 | beforeEach(() => {
17 | fixture = TestBed.createComponent(CreateEmployeeComponent);
18 | component = fixture.componentInstance;
19 | fixture.detectChanges();
20 | });
21 |
22 | it('should create', () => {
23 | expect(component).toBeTruthy();
24 | });
25 | });
26 |
--------------------------------------------------------------------------------
/angular-6-springboot-client/src/app/create-employee/create-employee.component.ts:
--------------------------------------------------------------------------------
1 | import { EmployeeService } from './../employee.service';
2 | import { Employee } from './../employee';
3 | import { Component, OnInit } from '@angular/core';
4 |
5 | @Component({
6 | selector: 'app-create-employee',
7 | templateUrl: './create-employee.component.html',
8 | styleUrls: ['./create-employee.component.css']
9 | })
10 | export class CreateEmployeeComponent implements OnInit {
11 |
12 | employee: Employee = new Employee();
13 | submitted = false;
14 |
15 | constructor(private employeeService: EmployeeService) { }
16 |
17 | ngOnInit() {
18 | }
19 |
20 | newEmployee(): void {
21 | this.submitted = false;
22 | this.employee = new Employee();
23 | }
24 |
25 | save() {
26 | this.employeeService.createEmployee(this.employee)
27 | .subscribe(data => console.log(data), error => console.log(error));
28 | this.employee = new Employee();
29 | }
30 |
31 | onSubmit() {
32 | this.submitted = true;
33 | this.save();
34 | }
35 | }
36 |
--------------------------------------------------------------------------------
/angular-6-springboot-client/src/app/employee-details/employee-details.component.css:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RameshMF/angular6-springboot-crud-tutorial/f3f0ec7b0bb973df7237f740d0b4d0876d247cf4/angular-6-springboot-client/src/app/employee-details/employee-details.component.css
--------------------------------------------------------------------------------
/angular-6-springboot-client/src/app/employee-details/employee-details.component.html:
--------------------------------------------------------------------------------
1 |
2 |
3 | {{employee.firstName}}
4 |
5 |
6 | {{employee.lastName}}
7 |
8 |
9 | {{employee.emailId}}
10 |
11 |
12 | {{employee.active}}
13 |
14 |
15 |
Inactive
16 |
17 |
Active
18 |
19 |
Delete
20 |
21 |
22 |
23 |
--------------------------------------------------------------------------------
/angular-6-springboot-client/src/app/employee-details/employee-details.component.spec.ts:
--------------------------------------------------------------------------------
1 | import { async, ComponentFixture, TestBed } from '@angular/core/testing';
2 |
3 | import { EmployeeDetailsComponent } from './employee-details.component';
4 |
5 | describe('EmployeeDetailsComponent', () => {
6 | let component: EmployeeDetailsComponent;
7 | let fixture: ComponentFixture;
8 |
9 | beforeEach(async(() => {
10 | TestBed.configureTestingModule({
11 | declarations: [ EmployeeDetailsComponent ]
12 | })
13 | .compileComponents();
14 | }));
15 |
16 | beforeEach(() => {
17 | fixture = TestBed.createComponent(EmployeeDetailsComponent);
18 | component = fixture.componentInstance;
19 | fixture.detectChanges();
20 | });
21 |
22 | it('should create', () => {
23 | expect(component).toBeTruthy();
24 | });
25 | });
26 |
--------------------------------------------------------------------------------
/angular-6-springboot-client/src/app/employee-details/employee-details.component.ts:
--------------------------------------------------------------------------------
1 | import { Employee } from './../employee';
2 | import { Component, OnInit, Input } from '@angular/core';
3 | import { EmployeeService } from '../employee.service';
4 | import { EmployeeListComponent } from '../employee-list/employee-list.component';
5 |
6 | @Component({
7 | selector: 'app-employee-details',
8 | templateUrl: './employee-details.component.html',
9 | styleUrls: ['./employee-details.component.css']
10 | })
11 | export class EmployeeDetailsComponent implements OnInit {
12 |
13 | @Input() employee: Employee;
14 |
15 | constructor(private employeeService: EmployeeService, private listComponent: EmployeeListComponent) { }
16 |
17 | ngOnInit() {
18 | }
19 |
20 | }
21 |
--------------------------------------------------------------------------------
/angular-6-springboot-client/src/app/employee-list/employee-list.component.css:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RameshMF/angular6-springboot-crud-tutorial/f3f0ec7b0bb973df7237f740d0b4d0876d247cf4/angular-6-springboot-client/src/app/employee-list/employee-list.component.css
--------------------------------------------------------------------------------
/angular-6-springboot-client/src/app/employee-list/employee-list.component.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
Employees
4 |
5 |
6 |
7 |
8 |
9 | Firstname |
10 | Lastname |
11 | Email |
12 | Actions |
13 |
14 |
15 |
16 |
17 | {{employee.firstName}} |
18 | {{employee.lastName}} |
19 | {{employee.emailId}} |
20 |
21 | |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
--------------------------------------------------------------------------------
/angular-6-springboot-client/src/app/employee-list/employee-list.component.spec.ts:
--------------------------------------------------------------------------------
1 | import { async, ComponentFixture, TestBed } from '@angular/core/testing';
2 |
3 | import { EmployeeListComponent } from './employee-list.component';
4 |
5 | describe('EmployeeListComponent', () => {
6 | let component: EmployeeListComponent;
7 | let fixture: ComponentFixture;
8 |
9 | beforeEach(async(() => {
10 | TestBed.configureTestingModule({
11 | declarations: [ EmployeeListComponent ]
12 | })
13 | .compileComponents();
14 | }));
15 |
16 | beforeEach(() => {
17 | fixture = TestBed.createComponent(EmployeeListComponent);
18 | component = fixture.componentInstance;
19 | fixture.detectChanges();
20 | });
21 |
22 | it('should create', () => {
23 | expect(component).toBeTruthy();
24 | });
25 | });
26 |
--------------------------------------------------------------------------------
/angular-6-springboot-client/src/app/employee-list/employee-list.component.ts:
--------------------------------------------------------------------------------
1 | import { EmployeeDetailsComponent } from './../employee-details/employee-details.component';
2 | import { Observable } from "rxjs";
3 | import { EmployeeService } from "./../employee.service";
4 | import { Employee } from "./../employee";
5 | import { Component, OnInit } from "@angular/core";
6 | import { Router } from '@angular/router';
7 |
8 | @Component({
9 | selector: "app-employee-list",
10 | templateUrl: "./employee-list.component.html",
11 | styleUrls: ["./employee-list.component.css"]
12 | })
13 | export class EmployeeListComponent implements OnInit {
14 | employees: Observable;
15 |
16 | constructor(private employeeService: EmployeeService,
17 | private router: Router) {}
18 |
19 | ngOnInit() {
20 | this.reloadData();
21 | }
22 |
23 | reloadData() {
24 | this.employees = this.employeeService.getEmployeesList();
25 | }
26 |
27 | deleteEmployee(id: number) {
28 | this.employeeService.deleteEmployee(id)
29 | .subscribe(
30 | data => {
31 | console.log(data);
32 | this.reloadData();
33 | },
34 | error => console.log(error));
35 | }
36 | }
37 |
--------------------------------------------------------------------------------
/angular-6-springboot-client/src/app/employee.service.spec.ts:
--------------------------------------------------------------------------------
1 | import { TestBed } from '@angular/core/testing';
2 |
3 | import { EmployeeService } from './employee.service';
4 |
5 | describe('EmployeeService', () => {
6 | beforeEach(() => TestBed.configureTestingModule({}));
7 |
8 | it('should be created', () => {
9 | const service: EmployeeService = TestBed.get(EmployeeService);
10 | expect(service).toBeTruthy();
11 | });
12 | });
13 |
--------------------------------------------------------------------------------
/angular-6-springboot-client/src/app/employee.service.ts:
--------------------------------------------------------------------------------
1 | import { Injectable } from '@angular/core';
2 | import { HttpClient } from '@angular/common/http';
3 | import { Observable } from 'rxjs';
4 |
5 | @Injectable({
6 | providedIn: 'root'
7 | })
8 | export class EmployeeService {
9 |
10 | private baseUrl = '/api/v1/employees';
11 |
12 | constructor(private http: HttpClient) { }
13 |
14 | getEmployee(id: number): Observable