Tuesday, August 28, 2018

Angular7 Creating First Application

Below you will find how to configure the solution architecture for Angular 7 using Visual Studio Code as editor.

Below are the prerequisites to create Angular 7 Application:

Use below instructions/steps to start creating your first Angular 7 application:

  • Create new folder in your drive where you want to keep the code base
  • Launch Visual Studio Code editor and select the created folder using File -> Open -> Select Folder
  • Create new file and name it as package.json under the project folder and paste below code. This file contains all the dependencies of the project.
  • {
      "name": "angular7-demo",
      "version": "0.0.0",
      "description": "QuickStart package.json from the documentation, supplemented with testing support",
      "scripts": {
        "ng": "ng" ",
        "start": "ng serve" ",
        "build": "ng build",
        "test": "ng test",
        "lint": "ng lint",
        "e2e": "ng e2e"
      },
      "private": true,
      "dependencies": {
        "@angular/animations": "~7.0.0",
        "@angular/common": "~7.0.0",
        "@angular/compiler": "~7.0.0",
        "@angular/core": "~7.0.0",
        "@angular/forms": "~7.0.0",
        "@angular/http": "~7.0.0",
        "@angular/platform-browser": "~7.0.0",
        "@angular/platform-browser-dynamic": "~7.0.0",
        "@angular/router": "~7.0.0",
        "angular-font-awesome": "^3.1.2",
        "core-js": "^2.5.4",
        "font-awesome": "^4.7.0",
        "ngx-pagination": "^3.2.1",
        "rxjs": "~6.3.3",
        "rxjs-compat": "^6.3.3",
        "underscore": "^1.9.1",
        "zone.js": "~0.8.26"
      },
      "devDependencies": {
        "@angular-devkit/build-angular": "~0.10.0",
        "@angular/cli": "~7.0.2",
        "@angular/compiler-cli": "~7.0.0",
        "@angular/language-service": "~7.0.0",
        "@types/jasmine": "~2.8.8",
        "@types/jasminewd2": "~2.0.3",
        "@types/node": "~8.9.4",
        "bootstrap": "^3.3.7",
        "codelyzer": "~4.5.0",
        "jasmine-core": "~2.99.1",
        "jasmine-spec-reporter": "~4.2.1",
        "karma": "~3.0.0",
        "karma-chrome-launcher": "~2.2.0",
        "karma-coverage-istanbul-reporter": "~2.0.1",
        "karma-jasmine": "~1.1.2",
        "karma-jasmine-html-reporter": "^0.2.2",
        "protractor": "~5.4.0",
        "ts-node": "~7.0.0",
        "tslint": "~5.11.0",
        "typescript": "~3.1.1"
      }
    }
  • Create another file and name it as tsconfig.json and paste below code. This file helps guide compiler as it generates JavaScript files.
  • {
      "compileOnSave": false,
      "compilerOptions": {
        "baseUrl": "./",
        "outDir": "./dist/out-tsc",
        "sourceMap": true,
        "declaration": false,
        "module": "es2015",
        "moduleResolution": "node",
        "emitDecoratorMetadata": true,
        "experimentalDecorators": true,
        "target": "es5",
        "typeRoots": [
              "node_modules/@types"
        ],
        "typeRoots": [
              "es2018",
              "dom"
        ]
      }
    }
  • Create another file and name it as tslint.json. This is a static analysis tool which will help to check code readability, maintainability, and functionality errors.
  • {
      "rulesDirectory": [
        "arrow-return-shorthand": true
      ]
    }
  • Launch Integrated Command Terminal using View tab to install dependencies. Use npm install command to start installing the dependencies.
  • After above step, you should see node_modules and package-lock.json files created in your solution. Which is a good sign, if not, check back
  • Create two more configuration files to handle version controlling and editor configurations namely .gitignore and .editorconfig
  • Create new folder and name it as src which contains all application related folders and files in it.

You are good to run your first Angular 7 application. Using Integrated Command Terminal run ng serve --open command to launch and run the above created application.

Happy Programming !!!

No comments:

Post a Comment