Setting up Angular project environment
1. Angular CLI Installation:-
• Angular CLI is required to create project, generate code library and application as well for testing, deployment and bundling.
• Npm is used for installing Angular CLI
- Cmd Command :- npm install -g @angular/cli
2. Workspace & Angular application creation:-
• Go to desirable location in system directory via cmd command.
• Use CLI Command (ng new) and give the required project name (e.g., - my-new-app)
- Cmd Command:- ng new my-new-app
• ng new command will prompt features/libraries to be included for initial app creation. Press enter to accept the same.
3. Run Application command:-
• Go to the project location via cmd.
• Execute command as below to start the server.
- Cmd command: - cd my-new-app
- Cmd command: - ng serve –o/--open
- --o will automatically open the pre-installed angular server on port- 4200 (http://localhost:4200/)
4. Create new component in project:-
• Always prefer to create new component with in a common directory.
• This helps in maintaining the project structure.
• Helpful for programmer to navigate easily with in project
• Easy in development and code readability.
• To create component use CLI command (ng g c/ ng generate component) and give the required component name (Header/ Common/Header).
- Cmd command:- ng g c Common/Header
5. To update type script of project for specific version:-
• To resolve type script version specific error, below command help in working
- Cmd command: - npm i –save -dev email@example.com
6. To uninstall Type script of project: -
• Below command help in working
- Cmd command:- npm uninstall typescript
7. Force update the project:-
• This helps in maintaining the project updated.
- Cmd command:- ng update –all --force