├── .editorconfig ├── .gitignore ├── LICENSE ├── README.md ├── angular.json ├── e2e ├── protractor.conf.js ├── src │ ├── app.e2e-spec.ts │ └── app.po.ts └── tsconfig.e2e.json ├── package.json ├── src ├── app │ ├── api.service.spec.ts │ ├── api.service.ts │ ├── app-routing.module.ts │ ├── app.component.html │ ├── app.component.scss │ ├── app.component.spec.ts │ ├── app.component.ts │ ├── app.module.ts │ ├── product-add │ │ ├── product-add.component.html │ │ ├── product-add.component.scss │ │ ├── product-add.component.spec.ts │ │ └── product-add.component.ts │ ├── product-detail │ │ ├── product-detail.component.html │ │ ├── product-detail.component.scss │ │ ├── product-detail.component.spec.ts │ │ └── product-detail.component.ts │ ├── product-edit │ │ ├── product-edit.component.html │ │ ├── product-edit.component.scss │ │ ├── product-edit.component.spec.ts │ │ └── product-edit.component.ts │ ├── product.ts │ └── products │ │ ├── products.component.html │ │ ├── products.component.scss │ │ ├── products.component.spec.ts │ │ └── products.component.ts ├── assets │ └── .gitkeep ├── browserslist ├── environments │ ├── environment.prod.ts │ └── environment.ts ├── favicon.ico ├── index.html ├── karma.conf.js ├── main.ts ├── polyfills.ts ├── styles.scss ├── test.ts ├── tsconfig.app.json ├── tsconfig.spec.json └── tslint.json ├── tsconfig.json └── tslint.json /.editorconfig: -------------------------------------------------------------------------------- 1 | # Editor configuration, see http://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 | -------------------------------------------------------------------------------- /.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 | # IDEs and editors 12 | /.idea 13 | .project 14 | .classpath 15 | .c9/ 16 | *.launch 17 | .settings/ 18 | *.sublime-workspace 19 | 20 | # IDE - VSCode 21 | .vscode/* 22 | !.vscode/settings.json 23 | !.vscode/tasks.json 24 | !.vscode/launch.json 25 | !.vscode/extensions.json 26 | 27 | # misc 28 | /.sass-cache 29 | /connect.lock 30 | /coverage 31 | /libpeerconnection.log 32 | npm-debug.log 33 | yarn-error.log 34 | testem.log 35 | /typings 36 | 37 | # System Files 38 | .DS_Store 39 | Thumbs.db 40 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2018 Didin Jamaludin 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Angular 7 Tutorial: Building CRUD Web Application 2 | 3 | This source code is part of [Angular 7 Tutorial: Building CRUD Web Application](https://www.djamware.com/post/5bca67d780aca7466989441f/angular-7-tutorial-building-crud-web-application) tutorial. 4 | 5 | This project was generated with [Angular CLI](https://github.com/angular/angular-cli) version 7.0.1. 6 | 7 | ## Development server 8 | 9 | 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. 10 | 11 | ## Code scaffolding 12 | 13 | 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`. 14 | 15 | ## Build 16 | 17 | 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. 18 | 19 | ## Running unit tests 20 | 21 | Run `ng test` to execute the unit tests via [Karma](https://karma-runner.github.io). 22 | 23 | ## Running end-to-end tests 24 | 25 | Run `ng e2e` to execute the end-to-end tests via [Protractor](http://www.protractortest.org/). 26 | 27 | ## Further help 28 | 29 | 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). 30 | -------------------------------------------------------------------------------- /angular.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "./node_modules/@angular/cli/lib/config/schema.json", 3 | "version": 1, 4 | "newProjectRoot": "projects", 5 | "projects": { 6 | "angular7-crud": { 7 | "root": "", 8 | "sourceRoot": "src", 9 | "projectType": "application", 10 | "prefix": "app", 11 | "schematics": { 12 | "@schematics/angular:component": { 13 | "styleext": "scss" 14 | } 15 | }, 16 | "architect": { 17 | "build": { 18 | "builder": "@angular-devkit/build-angular:browser", 19 | "options": { 20 | "outputPath": "dist/angular7-crud", 21 | "index": "src/index.html", 22 | "main": "src/main.ts", 23 | "polyfills": "src/polyfills.ts", 24 | "tsConfig": "src/tsconfig.app.json", 25 | "assets": [ 26 | "src/favicon.ico", 27 | "src/assets" 28 | ], 29 | "styles": [ 30 | "./node_modules/@angular/material/prebuilt-themes/purple-green.css", 31 | "src/styles.scss" 32 | ], 33 | "scripts": [] 34 | }, 35 | "configurations": { 36 | "production": { 37 | "fileReplacements": [ 38 | { 39 | "replace": "src/environments/environment.ts", 40 | "with": "src/environments/environment.prod.ts" 41 | } 42 | ], 43 | "optimization": true, 44 | "outputHashing": "all", 45 | "sourceMap": false, 46 | "extractCss": true, 47 | "namedChunks": false, 48 | "aot": true, 49 | "extractLicenses": true, 50 | "vendorChunk": false, 51 | "buildOptimizer": true, 52 | "budgets": [ 53 | { 54 | "type": "initial", 55 | "maximumWarning": "2mb", 56 | "maximumError": "5mb" 57 | } 58 | ] 59 | } 60 | } 61 | }, 62 | "serve": { 63 | "builder": "@angular-devkit/build-angular:dev-server", 64 | "options": { 65 | "browserTarget": "angular7-crud:build" 66 | }, 67 | "configurations": { 68 | "production": { 69 | "browserTarget": "angular7-crud:build:production" 70 | } 71 | } 72 | }, 73 | "extract-i18n": { 74 | "builder": "@angular-devkit/build-angular:extract-i18n", 75 | "options": { 76 | "browserTarget": "angular7-crud:build" 77 | } 78 | }, 79 | "test": { 80 | "builder": "@angular-devkit/build-angular:karma", 81 | "options": { 82 | "main": "src/test.ts", 83 | "polyfills": "src/polyfills.ts", 84 | "tsConfig": "src/tsconfig.spec.json", 85 | "karmaConfig": "src/karma.conf.js", 86 | "styles": [ 87 | "./node_modules/@angular/material/prebuilt-themes/purple-green.css", 88 | "src/styles.scss" 89 | ], 90 | "scripts": [], 91 | "assets": [ 92 | "src/favicon.ico", 93 | "src/assets" 94 | ] 95 | } 96 | }, 97 | "lint": { 98 | "builder": "@angular-devkit/build-angular:tslint", 99 | "options": { 100 | "tsConfig": [ 101 | "src/tsconfig.app.json", 102 | "src/tsconfig.spec.json" 103 | ], 104 | "exclude": [ 105 | "**/node_modules/**" 106 | ] 107 | } 108 | } 109 | } 110 | }, 111 | "angular7-crud-e2e": { 112 | "root": "e2e/", 113 | "projectType": "application", 114 | "prefix": "", 115 | "architect": { 116 | "e2e": { 117 | "builder": "@angular-devkit/build-angular:protractor", 118 | "options": { 119 | "protractorConfig": "e2e/protractor.conf.js", 120 | "devServerTarget": "angular7-crud:serve" 121 | }, 122 | "configurations": { 123 | "production": { 124 | "devServerTarget": "angular7-crud:serve:production" 125 | } 126 | } 127 | }, 128 | "lint": { 129 | "builder": "@angular-devkit/build-angular:tslint", 130 | "options": { 131 | "tsConfig": "e2e/tsconfig.e2e.json", 132 | "exclude": [ 133 | "**/node_modules/**" 134 | ] 135 | } 136 | } 137 | } 138 | } 139 | }, 140 | "defaultProject": "angular7-crud" 141 | } -------------------------------------------------------------------------------- /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 | }; -------------------------------------------------------------------------------- /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.getParagraphText()).toEqual('Welcome to angular7-crud!'); 13 | }); 14 | }); 15 | -------------------------------------------------------------------------------- /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 | getParagraphText() { 9 | return element(by.css('app-root h1')).getText(); 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /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 | } -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "angular7-crud", 3 | "version": "0.0.0", 4 | "scripts": { 5 | "ng": "ng", 6 | "start": "ng serve", 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.0.0", 15 | "@angular/cdk": "^7.0.0", 16 | "@angular/common": "~7.0.0", 17 | "@angular/compiler": "~7.0.0", 18 | "@angular/core": "~7.0.0", 19 | "@angular/forms": "~7.0.0", 20 | "@angular/http": "~7.0.0", 21 | "@angular/material": "^7.0.0", 22 | "@angular/platform-browser": "~7.0.0", 23 | "@angular/platform-browser-dynamic": "~7.0.0", 24 | "@angular/router": "~7.0.0", 25 | "core-js": "^2.5.4", 26 | "hammerjs": "^2.0.8", 27 | "rxjs": "~6.3.3", 28 | "zone.js": "~0.8.26" 29 | }, 30 | "devDependencies": { 31 | "@angular-devkit/build-angular": "~0.10.0", 32 | "@angular/cli": "~7.0.1", 33 | "@angular/compiler-cli": "~7.0.0", 34 | "@angular/language-service": "~7.0.0", 35 | "@types/node": "~8.9.4", 36 | "@types/jasmine": "~2.8.8", 37 | "@types/jasminewd2": "~2.0.3", 38 | "codelyzer": "~4.5.0", 39 | "jasmine-core": "~2.99.1", 40 | "jasmine-spec-reporter": "~4.2.1", 41 | "karma": "~3.0.0", 42 | "karma-chrome-launcher": "~2.2.0", 43 | "karma-coverage-istanbul-reporter": "~2.0.1", 44 | "karma-jasmine": "~1.1.2", 45 | "karma-jasmine-html-reporter": "^0.2.2", 46 | "protractor": "~5.4.0", 47 | "ts-node": "~7.0.0", 48 | "tslint": "~5.11.0", 49 | "typescript": "~3.1.1" 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /src/app/api.service.spec.ts: -------------------------------------------------------------------------------- 1 | import { TestBed } from '@angular/core/testing'; 2 | 3 | import { ApiService } from './api.service'; 4 | 5 | describe('ApiService', () => { 6 | beforeEach(() => TestBed.configureTestingModule({})); 7 | 8 | it('should be created', () => { 9 | const service: ApiService = TestBed.get(ApiService); 10 | expect(service).toBeTruthy(); 11 | }); 12 | }); 13 | -------------------------------------------------------------------------------- /src/app/api.service.ts: -------------------------------------------------------------------------------- 1 | import { Injectable } from '@angular/core'; 2 | import { Observable, of, throwError } from 'rxjs'; 3 | import { HttpClient, HttpHeaders, HttpErrorResponse } from '@angular/common/http'; 4 | import { catchError, tap, map } from 'rxjs/operators'; 5 | import { Product } from './product'; 6 | 7 | const httpOptions = { 8 | headers: new HttpHeaders({'Content-Type': 'application/json'}) 9 | }; 10 | const apiUrl = "http://localhost:3000/api/v1/products"; 11 | 12 | @Injectable({ 13 | providedIn: 'root' 14 | }) 15 | export class ApiService { 16 | 17 | constructor(private http: HttpClient) { } 18 | 19 | getProducts (): Observable { 20 | return this.http.get(apiUrl) 21 | .pipe( 22 | tap(products => console.log('Fetch products')), 23 | catchError(this.handleError('getProducts', [])) 24 | ); 25 | } 26 | 27 | getProduct(id: number): Observable { 28 | const url = `${apiUrl}/${id}`; 29 | return this.http.get(url).pipe( 30 | tap(_ => console.log(`fetched product id=${id}`)), 31 | catchError(this.handleError(`getProduct id=${id}`)) 32 | ); 33 | } 34 | 35 | addProduct (product): Observable { 36 | return this.http.post(apiUrl, product, httpOptions).pipe( 37 | tap((product: Product) => console.log(`added product w/ id=${product._id}`)), 38 | catchError(this.handleError('addProduct')) 39 | ); 40 | } 41 | 42 | updateProduct (id, product): Observable { 43 | const url = `${apiUrl}/${id}`; 44 | return this.http.put(url, product, httpOptions).pipe( 45 | tap(_ => console.log(`updated product id=${id}`)), 46 | catchError(this.handleError('updateProduct')) 47 | ); 48 | } 49 | 50 | deleteProduct (id): Observable { 51 | const url = `${apiUrl}/${id}`; 52 | 53 | return this.http.delete(url, httpOptions).pipe( 54 | tap(_ => console.log(`deleted product id=${id}`)), 55 | catchError(this.handleError('deleteProduct')) 56 | ); 57 | } 58 | 59 | private handleError (operation = 'operation', result?: T) { 60 | return (error: any): Observable => { 61 | 62 | // TODO: send the error to remote logging infrastructure 63 | console.error(error); // log to console instead 64 | 65 | // Let the app keep running by returning an empty result. 66 | return of(result as T); 67 | }; 68 | } 69 | } 70 | -------------------------------------------------------------------------------- /src/app/app-routing.module.ts: -------------------------------------------------------------------------------- 1 | import { NgModule } from '@angular/core'; 2 | import { Routes, RouterModule } from '@angular/router'; 3 | import { ProductsComponent } from './products/products.component'; 4 | import { ProductDetailComponent } from './product-detail/product-detail.component'; 5 | import { ProductAddComponent } from './product-add/product-add.component'; 6 | import { ProductEditComponent } from './product-edit/product-edit.component'; 7 | 8 | const routes: Routes = [ 9 | { 10 | path: 'products', 11 | component: ProductsComponent, 12 | data: { title: 'List of Products' } 13 | }, 14 | { 15 | path: 'product-details/:id', 16 | component: ProductDetailComponent, 17 | data: { title: 'Product Details' } 18 | }, 19 | { 20 | path: 'product-add', 21 | component: ProductAddComponent, 22 | data: { title: 'Add Product' } 23 | }, 24 | { 25 | path: 'product-edit/:id', 26 | component: ProductEditComponent, 27 | data: { title: 'Edit Product' } 28 | }, 29 | { path: '', 30 | redirectTo: '/products', 31 | pathMatch: 'full' 32 | } 33 | ]; 34 | 35 | @NgModule({ 36 | imports: [RouterModule.forRoot(routes)], 37 | exports: [RouterModule] 38 | }) 39 | export class AppRoutingModule { } 40 | -------------------------------------------------------------------------------- /src/app/app.component.html: -------------------------------------------------------------------------------- 1 | 2 |
3 | Angular Logo 4 |
5 | 6 |
7 | 8 |
9 | -------------------------------------------------------------------------------- /src/app/app.component.scss: -------------------------------------------------------------------------------- 1 | .container { 2 | padding: 20px; 3 | } 4 | -------------------------------------------------------------------------------- /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 'angular7-crud'`, () => { 24 | const fixture = TestBed.createComponent(AppComponent); 25 | const app = fixture.debugElement.componentInstance; 26 | expect(app.title).toEqual('angular7-crud'); 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 angular7-crud!'); 34 | }); 35 | }); 36 | -------------------------------------------------------------------------------- /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.scss'] 7 | }) 8 | export class AppComponent { 9 | title = 'angular7-crud'; 10 | } 11 | -------------------------------------------------------------------------------- /src/app/app.module.ts: -------------------------------------------------------------------------------- 1 | import { BrowserModule } from '@angular/platform-browser'; 2 | import { NgModule } from '@angular/core'; 3 | 4 | import { AppRoutingModule } from './app-routing.module'; 5 | import { FormsModule, ReactiveFormsModule } from '@angular/forms'; 6 | import { HttpClientModule } from '@angular/common/http'; 7 | import { 8 | MatInputModule, 9 | MatPaginatorModule, 10 | MatProgressSpinnerModule, 11 | MatSortModule, 12 | MatTableModule, 13 | MatIconModule, 14 | MatButtonModule, 15 | MatCardModule, 16 | MatFormFieldModule } from "@angular/material"; 17 | import { BrowserAnimationsModule } from '@angular/platform-browser/animations'; 18 | import { AppComponent } from './app.component'; 19 | import { ProductsComponent } from './products/products.component'; 20 | import { ProductDetailComponent } from './product-detail/product-detail.component'; 21 | import { ProductAddComponent } from './product-add/product-add.component'; 22 | import { ProductEditComponent } from './product-edit/product-edit.component'; 23 | 24 | @NgModule({ 25 | declarations: [ 26 | AppComponent, 27 | ProductsComponent, 28 | ProductDetailComponent, 29 | ProductAddComponent, 30 | ProductEditComponent 31 | ], 32 | imports: [ 33 | BrowserModule, 34 | FormsModule, 35 | HttpClientModule, 36 | AppRoutingModule, 37 | ReactiveFormsModule, 38 | BrowserAnimationsModule, 39 | MatInputModule, 40 | MatTableModule, 41 | MatPaginatorModule, 42 | MatSortModule, 43 | MatProgressSpinnerModule, 44 | MatIconModule, 45 | MatButtonModule, 46 | MatCardModule, 47 | MatFormFieldModule 48 | ], 49 | providers: [], 50 | bootstrap: [AppComponent] 51 | }) 52 | export class AppModule { } 53 | -------------------------------------------------------------------------------- /src/app/product-add/product-add.component.html: -------------------------------------------------------------------------------- 1 |
2 |
4 | 5 |
6 |
7 | list 8 |
9 | 10 |
11 | 12 | 14 | 15 | Please enter Product Name 16 | 17 | 18 | 19 | 21 | 22 | Please enter Product Description 23 | 24 | 25 | 26 | 28 | 29 | Please enter Product Price 30 | 31 | 32 |
33 | 34 |
35 |
36 |
37 |
38 | -------------------------------------------------------------------------------- /src/app/product-add/product-add.component.scss: -------------------------------------------------------------------------------- 1 | /* Structure */ 2 | .example-container { 3 | position: relative; 4 | padding: 5px; 5 | } 6 | 7 | .example-form { 8 | min-width: 150px; 9 | max-width: 500px; 10 | width: 100%; 11 | } 12 | 13 | .example-full-width { 14 | width: 100%; 15 | } 16 | 17 | .example-full-width:nth-last-child() { 18 | margin-bottom: 10px; 19 | } 20 | 21 | .button-row { 22 | margin: 10px 0; 23 | } 24 | 25 | .mat-flat-button { 26 | margin: 5px; 27 | } 28 | -------------------------------------------------------------------------------- /src/app/product-add/product-add.component.spec.ts: -------------------------------------------------------------------------------- 1 | import { async, ComponentFixture, TestBed } from '@angular/core/testing'; 2 | 3 | import { ProductAddComponent } from './product-add.component'; 4 | 5 | describe('ProductAddComponent', () => { 6 | let component: ProductAddComponent; 7 | let fixture: ComponentFixture; 8 | 9 | beforeEach(async(() => { 10 | TestBed.configureTestingModule({ 11 | declarations: [ ProductAddComponent ] 12 | }) 13 | .compileComponents(); 14 | })); 15 | 16 | beforeEach(() => { 17 | fixture = TestBed.createComponent(ProductAddComponent); 18 | component = fixture.componentInstance; 19 | fixture.detectChanges(); 20 | }); 21 | 22 | it('should create', () => { 23 | expect(component).toBeTruthy(); 24 | }); 25 | }); 26 | -------------------------------------------------------------------------------- /src/app/product-add/product-add.component.ts: -------------------------------------------------------------------------------- 1 | import { Component, OnInit } from '@angular/core'; 2 | import { Router } from '@angular/router'; 3 | import { ApiService } from '../api.service'; 4 | import { FormControl, FormGroupDirective, FormBuilder, FormGroup, NgForm, Validators } from '@angular/forms'; 5 | 6 | @Component({ 7 | selector: 'app-product-add', 8 | templateUrl: './product-add.component.html', 9 | styleUrls: ['./product-add.component.scss'] 10 | }) 11 | export class ProductAddComponent implements OnInit { 12 | 13 | productForm: FormGroup; 14 | prod_name:string=''; 15 | prod_desc:string=''; 16 | prod_price:number=null; 17 | isLoadingResults = false; 18 | 19 | constructor(private router: Router, private api: ApiService, private formBuilder: FormBuilder) { } 20 | 21 | ngOnInit() { 22 | this.productForm = this.formBuilder.group({ 23 | 'prod_name' : [null, Validators.required], 24 | 'prod_desc' : [null, Validators.required], 25 | 'prod_price' : [null, Validators.required] 26 | }); 27 | } 28 | 29 | onFormSubmit(form:NgForm) { 30 | this.isLoadingResults = true; 31 | this.api.addProduct(form) 32 | .subscribe(res => { 33 | let id = res['_id']; 34 | this.isLoadingResults = false; 35 | this.router.navigate(['/product-details', id]); 36 | }, (err) => { 37 | console.log(err); 38 | this.isLoadingResults = false; 39 | }); 40 | } 41 | 42 | } 43 | -------------------------------------------------------------------------------- /src/app/product-detail/product-detail.component.html: -------------------------------------------------------------------------------- 1 |
2 |
4 | 5 |
6 |
7 | list 8 |
9 | 10 | 11 |

{{product.prod_name}}

12 | {{product.prod_desc}} 13 |
14 | 15 |
16 |
Product Price:
17 |
{{product.prod_price}}
18 |
Updated At:
19 |
{{product.updated_at | date}}
20 |
21 |
22 | 23 | edit 24 | delete 25 | 26 |
27 |
28 | -------------------------------------------------------------------------------- /src/app/product-detail/product-detail.component.scss: -------------------------------------------------------------------------------- 1 | /* Structure */ 2 | .example-container { 3 | position: relative; 4 | padding: 5px; 5 | } 6 | 7 | .example-loading-shade { 8 | position: absolute; 9 | top: 0; 10 | left: 0; 11 | bottom: 56px; 12 | right: 0; 13 | background: rgba(0, 0, 0, 0.15); 14 | z-index: 1; 15 | display: flex; 16 | align-items: center; 17 | justify-content: center; 18 | } 19 | 20 | .mat-flat-button { 21 | margin: 5px; 22 | } 23 | -------------------------------------------------------------------------------- /src/app/product-detail/product-detail.component.spec.ts: -------------------------------------------------------------------------------- 1 | import { async, ComponentFixture, TestBed } from '@angular/core/testing'; 2 | 3 | import { ProductDetailComponent } from './product-detail.component'; 4 | 5 | describe('ProductDetailComponent', () => { 6 | let component: ProductDetailComponent; 7 | let fixture: ComponentFixture; 8 | 9 | beforeEach(async(() => { 10 | TestBed.configureTestingModule({ 11 | declarations: [ ProductDetailComponent ] 12 | }) 13 | .compileComponents(); 14 | })); 15 | 16 | beforeEach(() => { 17 | fixture = TestBed.createComponent(ProductDetailComponent); 18 | component = fixture.componentInstance; 19 | fixture.detectChanges(); 20 | }); 21 | 22 | it('should create', () => { 23 | expect(component).toBeTruthy(); 24 | }); 25 | }); 26 | -------------------------------------------------------------------------------- /src/app/product-detail/product-detail.component.ts: -------------------------------------------------------------------------------- 1 | import { Component, OnInit } from '@angular/core'; 2 | import { ActivatedRoute, Router } from '@angular/router'; 3 | import { ApiService } from '../api.service'; 4 | import { Product } from '../product'; 5 | 6 | @Component({ 7 | selector: 'app-product-detail', 8 | templateUrl: './product-detail.component.html', 9 | styleUrls: ['./product-detail.component.scss'] 10 | }) 11 | export class ProductDetailComponent implements OnInit { 12 | 13 | product: Product = { _id: '', prod_name: '', prod_desc: '', prod_price: null, updated_at: null }; 14 | isLoadingResults = true; 15 | 16 | constructor(private route: ActivatedRoute, private api: ApiService, private router: Router) { } 17 | 18 | ngOnInit() { 19 | console.log(this.route.snapshot.params['id']); 20 | this.getProductDetails(this.route.snapshot.params['id']); 21 | } 22 | 23 | getProductDetails(id) { 24 | this.api.getProduct(id) 25 | .subscribe(data => { 26 | this.product = data; 27 | console.log(this.product); 28 | this.isLoadingResults = false; 29 | }); 30 | } 31 | 32 | deleteProduct(id) { 33 | this.isLoadingResults = true; 34 | this.api.deleteProduct(id) 35 | .subscribe(res => { 36 | this.isLoadingResults = false; 37 | this.router.navigate(['/products']); 38 | }, (err) => { 39 | console.log(err); 40 | this.isLoadingResults = false; 41 | } 42 | ); 43 | } 44 | 45 | } 46 | -------------------------------------------------------------------------------- /src/app/product-edit/product-edit.component.html: -------------------------------------------------------------------------------- 1 |
2 |
4 | 5 |
6 |
7 | info 8 |
9 | 10 |
11 | 12 | 14 | 15 | Please enter Product Name 16 | 17 | 18 | 19 | 21 | 22 | Please enter Product Description 23 | 24 | 25 | 26 | 28 | 29 | Please enter Product Price 30 | 31 | 32 |
33 | 34 |
35 |
36 |
37 |
38 | -------------------------------------------------------------------------------- /src/app/product-edit/product-edit.component.scss: -------------------------------------------------------------------------------- 1 | /* Structure */ 2 | .example-container { 3 | position: relative; 4 | padding: 5px; 5 | } 6 | 7 | .example-form { 8 | min-width: 150px; 9 | max-width: 500px; 10 | width: 100%; 11 | } 12 | 13 | .example-full-width { 14 | width: 100%; 15 | } 16 | 17 | .example-full-width:nth-last-child() { 18 | margin-bottom: 10px; 19 | } 20 | 21 | .button-row { 22 | margin: 10px 0; 23 | } 24 | 25 | .mat-flat-button { 26 | margin: 5px; 27 | } 28 | -------------------------------------------------------------------------------- /src/app/product-edit/product-edit.component.spec.ts: -------------------------------------------------------------------------------- 1 | import { async, ComponentFixture, TestBed } from '@angular/core/testing'; 2 | 3 | import { ProductEditComponent } from './product-edit.component'; 4 | 5 | describe('ProductEditComponent', () => { 6 | let component: ProductEditComponent; 7 | let fixture: ComponentFixture; 8 | 9 | beforeEach(async(() => { 10 | TestBed.configureTestingModule({ 11 | declarations: [ ProductEditComponent ] 12 | }) 13 | .compileComponents(); 14 | })); 15 | 16 | beforeEach(() => { 17 | fixture = TestBed.createComponent(ProductEditComponent); 18 | component = fixture.componentInstance; 19 | fixture.detectChanges(); 20 | }); 21 | 22 | it('should create', () => { 23 | expect(component).toBeTruthy(); 24 | }); 25 | }); 26 | -------------------------------------------------------------------------------- /src/app/product-edit/product-edit.component.ts: -------------------------------------------------------------------------------- 1 | import { Component, OnInit } from '@angular/core'; 2 | import { Router, ActivatedRoute } from '@angular/router'; 3 | import { ApiService } from '../api.service'; 4 | import { FormControl, FormGroupDirective, FormBuilder, FormGroup, NgForm, Validators } from '@angular/forms'; 5 | 6 | @Component({ 7 | selector: 'app-product-edit', 8 | templateUrl: './product-edit.component.html', 9 | styleUrls: ['./product-edit.component.scss'] 10 | }) 11 | export class ProductEditComponent implements OnInit { 12 | 13 | productForm: FormGroup; 14 | _id:string=''; 15 | prod_name:string=''; 16 | prod_desc:string=''; 17 | prod_price:number=null; 18 | isLoadingResults = false; 19 | 20 | constructor(private router: Router, private route: ActivatedRoute, private api: ApiService, private formBuilder: FormBuilder) { } 21 | 22 | ngOnInit() { 23 | this.getProduct(this.route.snapshot.params['id']); 24 | this.productForm = this.formBuilder.group({ 25 | 'prod_name' : [null, Validators.required], 26 | 'prod_desc' : [null, Validators.required], 27 | 'prod_price' : [null, Validators.required] 28 | }); 29 | } 30 | 31 | getProduct(id) { 32 | this.api.getProduct(id).subscribe(data => { 33 | this._id = data._id; 34 | this.productForm.setValue({ 35 | prod_name: data.prod_name, 36 | prod_desc: data.prod_desc, 37 | prod_price: data.prod_price 38 | }); 39 | }); 40 | } 41 | 42 | onFormSubmit(form:NgForm) { 43 | this.isLoadingResults = true; 44 | this.api.updateProduct(this._id, form) 45 | .subscribe(res => { 46 | let id = res['_id']; 47 | this.isLoadingResults = false; 48 | this.router.navigate(['/product-details', id]); 49 | }, (err) => { 50 | console.log(err); 51 | this.isLoadingResults = false; 52 | } 53 | ); 54 | } 55 | 56 | productDetails() { 57 | this.router.navigate(['/product-details', this._id]); 58 | } 59 | 60 | } 61 | -------------------------------------------------------------------------------- /src/app/product.ts: -------------------------------------------------------------------------------- 1 | export class Product { 2 | _id: string; 3 | prod_name: string; 4 | prod_desc: string; 5 | prod_price: number; 6 | updated_at: Date; 7 | } 8 | -------------------------------------------------------------------------------- /src/app/products/products.component.html: -------------------------------------------------------------------------------- 1 |
2 |
4 | 5 |
6 |
7 | add 8 |
9 |
10 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 |
Product Name{{row.prod_name}}Product Price$ {{row.prod_price}}
28 |
29 |
30 | -------------------------------------------------------------------------------- /src/app/products/products.component.scss: -------------------------------------------------------------------------------- 1 | /* Structure */ 2 | .example-container { 3 | position: relative; 4 | padding: 5px; 5 | } 6 | 7 | .example-table-container { 8 | position: relative; 9 | max-height: 400px; 10 | overflow: auto; 11 | } 12 | 13 | table { 14 | width: 100%; 15 | } 16 | 17 | .example-loading-shade { 18 | position: absolute; 19 | top: 0; 20 | left: 0; 21 | bottom: 56px; 22 | right: 0; 23 | background: rgba(0, 0, 0, 0.15); 24 | z-index: 1; 25 | display: flex; 26 | align-items: center; 27 | justify-content: center; 28 | } 29 | 30 | .example-rate-limit-reached { 31 | color: #980000; 32 | max-width: 360px; 33 | text-align: center; 34 | } 35 | 36 | /* Column Widths */ 37 | .mat-column-number, 38 | .mat-column-state { 39 | max-width: 64px; 40 | } 41 | 42 | .mat-column-created { 43 | max-width: 124px; 44 | } 45 | 46 | .mat-flat-button { 47 | margin: 5px; 48 | } 49 | -------------------------------------------------------------------------------- /src/app/products/products.component.spec.ts: -------------------------------------------------------------------------------- 1 | import { async, ComponentFixture, TestBed } from '@angular/core/testing'; 2 | 3 | import { ProductsComponent } from './products.component'; 4 | 5 | describe('ProductsComponent', () => { 6 | let component: ProductsComponent; 7 | let fixture: ComponentFixture; 8 | 9 | beforeEach(async(() => { 10 | TestBed.configureTestingModule({ 11 | declarations: [ ProductsComponent ] 12 | }) 13 | .compileComponents(); 14 | })); 15 | 16 | beforeEach(() => { 17 | fixture = TestBed.createComponent(ProductsComponent); 18 | component = fixture.componentInstance; 19 | fixture.detectChanges(); 20 | }); 21 | 22 | it('should create', () => { 23 | expect(component).toBeTruthy(); 24 | }); 25 | }); 26 | -------------------------------------------------------------------------------- /src/app/products/products.component.ts: -------------------------------------------------------------------------------- 1 | import { Component, OnInit } from '@angular/core'; 2 | import { ApiService } from '../api.service'; 3 | import { Product } from '../product'; 4 | 5 | @Component({ 6 | selector: 'app-products', 7 | templateUrl: './products.component.html', 8 | styleUrls: ['./products.component.scss'] 9 | }) 10 | export class ProductsComponent implements OnInit { 11 | 12 | displayedColumns: string[] = ['prod_name', 'prod_price']; 13 | data: Product[] = []; 14 | isLoadingResults = true; 15 | 16 | constructor(private api: ApiService) { } 17 | 18 | ngOnInit() { 19 | this.api.getProducts() 20 | .subscribe(res => { 21 | this.data = res; 22 | console.log(this.data); 23 | this.isLoadingResults = false; 24 | }, err => { 25 | console.log(err); 26 | this.isLoadingResults = false; 27 | }); 28 | } 29 | 30 | } 31 | -------------------------------------------------------------------------------- /src/assets/.gitkeep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/didinj/angular7-material-crud-example/ffd6027eed72c998fe047044e6caa64a2615046a/src/assets/.gitkeep -------------------------------------------------------------------------------- /src/browserslist: -------------------------------------------------------------------------------- 1 | # This file is currently used by autoprefixer to adjust CSS to support the below specified browsers 2 | # For additional information regarding the format and rule options, please see: 3 | # https://github.com/browserslist/browserslist#queries 4 | # 5 | # For IE 9-11 support, please remove 'not' from the last line of the file and adjust as needed 6 | 7 | > 0.5% 8 | last 2 versions 9 | Firefox ESR 10 | not dead 11 | not IE 9-11 -------------------------------------------------------------------------------- /src/environments/environment.prod.ts: -------------------------------------------------------------------------------- 1 | export const environment = { 2 | production: true 3 | }; 4 | -------------------------------------------------------------------------------- /src/environments/environment.ts: -------------------------------------------------------------------------------- 1 | // This file can be replaced during build by using the `fileReplacements` array. 2 | // `ng build --prod` replaces `environment.ts` with `environment.prod.ts`. 3 | // The list of file replacements can be found in `angular.json`. 4 | 5 | export const environment = { 6 | production: false 7 | }; 8 | 9 | /* 10 | * For easier debugging in development mode, you can import the following file 11 | * to ignore zone related error stack frames such as `zone.run`, `zoneDelegate.invokeTask`. 12 | * 13 | * This import should be commented out in production mode because it will have a negative impact 14 | * on performance if an error is thrown. 15 | */ 16 | // import 'zone.js/dist/zone-error'; // Included with Angular CLI. 17 | -------------------------------------------------------------------------------- /src/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/didinj/angular7-material-crud-example/ffd6027eed72c998fe047044e6caa64a2615046a/src/favicon.ico -------------------------------------------------------------------------------- /src/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Angular7Crud 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /src/karma.conf.js: -------------------------------------------------------------------------------- 1 | // Karma configuration file, see link for more information 2 | // https://karma-runner.github.io/1.0/config/configuration-file.html 3 | 4 | module.exports = function (config) { 5 | config.set({ 6 | basePath: '', 7 | frameworks: ['jasmine', '@angular-devkit/build-angular'], 8 | plugins: [ 9 | require('karma-jasmine'), 10 | require('karma-chrome-launcher'), 11 | require('karma-jasmine-html-reporter'), 12 | require('karma-coverage-istanbul-reporter'), 13 | require('@angular-devkit/build-angular/plugins/karma') 14 | ], 15 | client: { 16 | clearContext: false // leave Jasmine Spec Runner output visible in browser 17 | }, 18 | coverageIstanbulReporter: { 19 | dir: require('path').join(__dirname, '../coverage'), 20 | reports: ['html', 'lcovonly'], 21 | fixWebpackSourcePaths: true 22 | }, 23 | reporters: ['progress', 'kjhtml'], 24 | port: 9876, 25 | colors: true, 26 | logLevel: config.LOG_INFO, 27 | autoWatch: true, 28 | browsers: ['Chrome'], 29 | singleRun: false 30 | }); 31 | }; -------------------------------------------------------------------------------- /src/main.ts: -------------------------------------------------------------------------------- 1 | import 'hammerjs'; 2 | import { enableProdMode } from '@angular/core'; 3 | import { platformBrowserDynamic } from '@angular/platform-browser-dynamic'; 4 | 5 | import { AppModule } from './app/app.module'; 6 | import { environment } from './environments/environment'; 7 | 8 | if (environment.production) { 9 | enableProdMode(); 10 | } 11 | 12 | platformBrowserDynamic().bootstrapModule(AppModule) 13 | .catch(err => console.error(err)); 14 | -------------------------------------------------------------------------------- /src/polyfills.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * This file includes polyfills needed by Angular and is loaded before the app. 3 | * You can add your own extra polyfills to this file. 4 | * 5 | * This file is divided into 2 sections: 6 | * 1. Browser polyfills. These are applied before loading ZoneJS and are sorted by browsers. 7 | * 2. Application imports. Files imported after ZoneJS that should be loaded before your main 8 | * file. 9 | * 10 | * The current setup is for so-called "evergreen" browsers; the last versions of browsers that 11 | * automatically update themselves. This includes Safari >= 10, Chrome >= 55 (including Opera), 12 | * Edge >= 13 on the desktop, and iOS 10 and Chrome on mobile. 13 | * 14 | * Learn more in https://angular.io/guide/browser-support 15 | */ 16 | 17 | /*************************************************************************************************** 18 | * BROWSER POLYFILLS 19 | */ 20 | 21 | /** IE9, IE10 and IE11 requires all of the following polyfills. **/ 22 | // import 'core-js/es6/symbol'; 23 | // import 'core-js/es6/object'; 24 | // import 'core-js/es6/function'; 25 | // import 'core-js/es6/parse-int'; 26 | // import 'core-js/es6/parse-float'; 27 | // import 'core-js/es6/number'; 28 | // import 'core-js/es6/math'; 29 | // import 'core-js/es6/string'; 30 | // import 'core-js/es6/date'; 31 | // import 'core-js/es6/array'; 32 | // import 'core-js/es6/regexp'; 33 | // import 'core-js/es6/map'; 34 | // import 'core-js/es6/weak-map'; 35 | // import 'core-js/es6/set'; 36 | 37 | /** 38 | * If the application will be indexed by Google Search, the following is required. 39 | * Googlebot uses a renderer based on Chrome 41. 40 | * https://developers.google.com/search/docs/guides/rendering 41 | **/ 42 | // import 'core-js/es6/array'; 43 | 44 | /** IE10 and IE11 requires the following for NgClass support on SVG elements */ 45 | // import 'classlist.js'; // Run `npm install --save classlist.js`. 46 | 47 | /** IE10 and IE11 requires the following for the Reflect API. */ 48 | // import 'core-js/es6/reflect'; 49 | 50 | /** 51 | * Web Animations `@angular/platform-browser/animations` 52 | * Only required if AnimationBuilder is used within the application and using IE/Edge or Safari. 53 | * Standard animation support in Angular DOES NOT require any polyfills (as of Angular 6.0). 54 | **/ 55 | // import 'web-animations-js'; // Run `npm install --save web-animations-js`. 56 | 57 | /** 58 | * By default, zone.js will patch all possible macroTask and DomEvents 59 | * user can disable parts of macroTask/DomEvents patch by setting following flags 60 | */ 61 | 62 | // (window as any).__Zone_disable_requestAnimationFrame = true; // disable patch requestAnimationFrame 63 | // (window as any).__Zone_disable_on_property = true; // disable patch onProperty such as onclick 64 | // (window as any).__zone_symbol__BLACK_LISTED_EVENTS = ['scroll', 'mousemove']; // disable patch specified eventNames 65 | 66 | /* 67 | * in IE/Edge developer tools, the addEventListener will also be wrapped by zone.js 68 | * with the following flag, it will bypass `zone.js` patch for IE/Edge 69 | */ 70 | // (window as any).__Zone_enable_cross_context_check = true; 71 | 72 | /*************************************************************************************************** 73 | * Zone JS is required by default for Angular itself. 74 | */ 75 | import 'zone.js/dist/zone'; // Included with Angular CLI. 76 | 77 | 78 | /*************************************************************************************************** 79 | * APPLICATION IMPORTS 80 | */ 81 | -------------------------------------------------------------------------------- /src/styles.scss: -------------------------------------------------------------------------------- 1 | /* You can add global styles to this file, and also import other style files */ 2 | 3 | html, body { height: 100%; } 4 | body { margin: 0; font-family: Roboto, "Helvetica Neue", sans-serif; } 5 | -------------------------------------------------------------------------------- /src/test.ts: -------------------------------------------------------------------------------- 1 | // This file is required by karma.conf.js and loads recursively all the .spec and framework files 2 | 3 | import 'zone.js/dist/zone-testing'; 4 | import { getTestBed } from '@angular/core/testing'; 5 | import { 6 | BrowserDynamicTestingModule, 7 | platformBrowserDynamicTesting 8 | } from '@angular/platform-browser-dynamic/testing'; 9 | 10 | declare const require: any; 11 | 12 | // First, initialize the Angular testing environment. 13 | getTestBed().initTestEnvironment( 14 | BrowserDynamicTestingModule, 15 | platformBrowserDynamicTesting() 16 | ); 17 | // Then we find all the tests. 18 | const context = require.context('./', true, /\.spec\.ts$/); 19 | // And load the modules. 20 | context.keys().map(context); 21 | -------------------------------------------------------------------------------- /src/tsconfig.app.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "../tsconfig.json", 3 | "compilerOptions": { 4 | "outDir": "../out-tsc/app", 5 | "types": [] 6 | }, 7 | "exclude": [ 8 | "test.ts", 9 | "**/*.spec.ts" 10 | ] 11 | } 12 | -------------------------------------------------------------------------------- /src/tsconfig.spec.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "../tsconfig.json", 3 | "compilerOptions": { 4 | "outDir": "../out-tsc/spec", 5 | "types": [ 6 | "jasmine", 7 | "node" 8 | ] 9 | }, 10 | "files": [ 11 | "test.ts", 12 | "polyfills.ts" 13 | ], 14 | "include": [ 15 | "**/*.spec.ts", 16 | "**/*.d.ts" 17 | ] 18 | } 19 | -------------------------------------------------------------------------------- /src/tslint.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "../tslint.json", 3 | "rules": { 4 | "directive-selector": [ 5 | true, 6 | "attribute", 7 | "app", 8 | "camelCase" 9 | ], 10 | "component-selector": [ 11 | true, 12 | "element", 13 | "app", 14 | "kebab-case" 15 | ] 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compileOnSave": false, 3 | "compilerOptions": { 4 | "baseUrl": "./", 5 | "outDir": "./dist/out-tsc", 6 | "sourceMap": true, 7 | "declaration": false, 8 | "module": "es2015", 9 | "moduleResolution": "node", 10 | "emitDecoratorMetadata": true, 11 | "experimentalDecorators": true, 12 | "target": "es5", 13 | "typeRoots": [ 14 | "node_modules/@types" 15 | ], 16 | "lib": [ 17 | "es2018", 18 | "dom" 19 | ] 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /tslint.json: -------------------------------------------------------------------------------- 1 | { 2 | "rulesDirectory": [ 3 | "node_modules/codelyzer" 4 | ], 5 | "rules": { 6 | "arrow-return-shorthand": true, 7 | "callable-types": true, 8 | "class-name": true, 9 | "comment-format": [ 10 | true, 11 | "check-space" 12 | ], 13 | "curly": true, 14 | "deprecation": { 15 | "severity": "warn" 16 | }, 17 | "eofline": true, 18 | "forin": true, 19 | "import-blacklist": [ 20 | true, 21 | "rxjs/Rx" 22 | ], 23 | "import-spacing": true, 24 | "indent": [ 25 | true, 26 | "spaces" 27 | ], 28 | "interface-over-type-literal": true, 29 | "label-position": true, 30 | "max-line-length": [ 31 | true, 32 | 140 33 | ], 34 | "member-access": false, 35 | "member-ordering": [ 36 | true, 37 | { 38 | "order": [ 39 | "static-field", 40 | "instance-field", 41 | "static-method", 42 | "instance-method" 43 | ] 44 | } 45 | ], 46 | "no-arg": true, 47 | "no-bitwise": true, 48 | "no-console": [ 49 | true, 50 | "debug", 51 | "info", 52 | "time", 53 | "timeEnd", 54 | "trace" 55 | ], 56 | "no-construct": true, 57 | "no-debugger": true, 58 | "no-duplicate-super": true, 59 | "no-empty": false, 60 | "no-empty-interface": true, 61 | "no-eval": true, 62 | "no-inferrable-types": [ 63 | true, 64 | "ignore-params" 65 | ], 66 | "no-misused-new": true, 67 | "no-non-null-assertion": true, 68 | "no-redundant-jsdoc": true, 69 | "no-shadowed-variable": true, 70 | "no-string-literal": false, 71 | "no-string-throw": true, 72 | "no-switch-case-fall-through": true, 73 | "no-trailing-whitespace": true, 74 | "no-unnecessary-initializer": true, 75 | "no-unused-expression": true, 76 | "no-use-before-declare": true, 77 | "no-var-keyword": true, 78 | "object-literal-sort-keys": false, 79 | "one-line": [ 80 | true, 81 | "check-open-brace", 82 | "check-catch", 83 | "check-else", 84 | "check-whitespace" 85 | ], 86 | "prefer-const": true, 87 | "quotemark": [ 88 | true, 89 | "single" 90 | ], 91 | "radix": true, 92 | "semicolon": [ 93 | true, 94 | "always" 95 | ], 96 | "triple-equals": [ 97 | true, 98 | "allow-null-check" 99 | ], 100 | "typedef-whitespace": [ 101 | true, 102 | { 103 | "call-signature": "nospace", 104 | "index-signature": "nospace", 105 | "parameter": "nospace", 106 | "property-declaration": "nospace", 107 | "variable-declaration": "nospace" 108 | } 109 | ], 110 | "unified-signatures": true, 111 | "variable-name": false, 112 | "whitespace": [ 113 | true, 114 | "check-branch", 115 | "check-decl", 116 | "check-operator", 117 | "check-separator", 118 | "check-type" 119 | ], 120 | "no-output-on-prefix": true, 121 | "use-input-property-decorator": true, 122 | "use-output-property-decorator": true, 123 | "use-host-property-decorator": true, 124 | "no-input-rename": true, 125 | "no-output-rename": true, 126 | "use-life-cycle-interface": true, 127 | "use-pipe-transform-interface": true, 128 | "component-class-suffix": true, 129 | "directive-class-suffix": true 130 | } 131 | } 132 | --------------------------------------------------------------------------------