Tuesday 10 September 2019

Angular getting started - part 1




Angular Getting Started
                                                                   
Prerequisites – Knowledge of Typescript, Basic HTML and CSS

Installation in windows
  Prerequisites:  Node.js and NPM
Make sure you have node and npm installed. Below commands should return response
·         node -v
·         npm -v

Command to install angular

                npm install -g @angular/cli

Note: if you under corporate proxy you might have to configure proxy to npm work properly

Verify successful installation and check version

                ng –version

To create project

                ng new <project_name>
                example: ng create my-first-angular-project       
               

To launch Angular application

ng serve
                To launch to different port than default
                ng serve –port 8080

Note: First time ng serve gave me error like ' The serve command requires to be run in an Angular project, but a project definition could not be found'

Solution: I was not inside the project folder so move inside the project folder and run the command again and It works. (Funny 😊).



Webpack –

                                Angular uses webpack build automation tool. The technique is also known as - HMR - HOT Module replacement / Hot module reloading. It means you do not need to restart the application for any changes in the component.



Create a component using angular cli

ng g c <componentName>
ng g c courses

To Create component inside of another component

ng g c Courses/course-details --skipTests
Note- skipTests can be used if you don’t want to generate test file for the component


Create a service using angular cli

ng g s [serviceName]


continued….

1 comment:

Make life easier — Git automation with single command file

Make life easier — Git automation with single command file Posted on medium #makelifeeasier series - Automation of git related activity...