6_Creating Core Module - mukeshrathore/base-project GitHub Wiki

Module Description

Core Module will have following components:

  1. Header
  2. Footer
  3. Navigation

Security folder falls under core module and it will have following .ts files

  1. authentication service
  2. route guard

Another folder 'route-error-handler' is part of the core module and will have following components:

  1. access-denied
  2. page-not-found
  3. session-timeout

##Module Create Command
ng generate module core and its short-hand command is ng g m core
generate component inside by using ng g c header command.
use similar command for creating other components.

using respective components

declare respective component and export it from core module. Import core module in app.module.ts. In case you are using any material component in any component then import lib module in core module as well.

using app version from package.json

"version" attr in package.json denotes our application version and whenever we push new changes to lower environments i.e. dev, sit, or uat we need to update our application to reflect that we have done some changes. Updated app version also helps us in knowing whether our new code is deployed successfully or not.
To use version attr from package.json into our application. Please follow below steps:

  1. ensure @types/node is installed npm install @types/node. you can verify it in package.json under "devDependencies" Object.
  2. go to tsconfig.json and ensure that you have "types":["node"] under compilerOptions Object
  3. declare VERSION:require('../../../../package.json').version under environment constant in environment.ts. Please note that environment.ts is only for developement purpose so make sure to declare VERSION constant in environment.prod.ts as well.
  4. we will be using app verison in footer component for now. declare a readdonly variable readonly version:string=environment.VERSION in footer.component.ts along with import statement import{environment}from '../../../environments/environment'
  5. if your code compilation failed die to @types/node then follow steps 2 './tsconfig.json' file.