6_Creating Core Module - mukeshrathore/base-project GitHub Wiki
Module Description
Core Module will have following components:
- Header
- Footer
- Navigation
Security folder falls under core module and it will have following .ts files
- authentication service
- route guard
Another folder 'route-error-handler' is part of the core module and will have following components:
- access-denied
- page-not-found
- 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:
- ensure @types/node is installed
npm install @types/node
. you can verify it in package.json under "devDependencies" Object. - go to tsconfig.json and ensure that you have
"types":["node"]
under compilerOptions Object - 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. - 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 statementimport{environment}from '../../../environments/environment'
- if your code compilation failed die to @types/node then follow steps 2 './tsconfig.json' file.