The easiest way to learn and setup Angular2

Introduction:

Angular2 is a MV* (Model-View-*) framework which enables to build rich UI applications for the mobile, TV, laptop, tablet etc.

  As above you can see MV* , there is ‘C’(Controller) is missing as in Angular2, the controller and many other things which were part of angular 1 have been removed. This framework is highly optimize and very efficient to accomplish many tasks.

Let’s jump into quick start to build an app and quick setup in Angular2

1. Install node(v6.7.0) and npm (3.10.3). Angular2 requires node version 6+ and npm version 3+ to start with. To download the correct version click here.

2. Once you are done with nodejs then verify the version as below command

3. If you are working behind a proxy then need to set the proxy for below else skip this step:

Window Command Prompt

NPM

GIT

4. Install angular cli

OR

5. Verify angular-cli installation

verify-angular2

6.Create first project

createfirstproj

7. Get into <projectName> dir

changedir-to-project

8. All the required dependencies are included in angular-cli.json file will created in project folder

project_dir_overview

9. There is a ‘src’ directory which has all files/dirs related to application.

app this is used to create all + angular2  component
assets  
environments environment specific setting file as prod, dev and test
favicon.ico  
index.html First page to initiate your application with AppComponent
main.ts To load all  angular2 component
polyfills.ts To load all library to compile the Angular2 component
styles.css  
test.ts To test the angular component
tsconfig.json Typescript library to load
typings.d.ts declare system to initialize

10. To start angular2 first app run below command:

run-app

11. The default port to run the angular2 is 4200

Open https://localhost:4200/

app_preview

12. If you see above message then congrats you have successfully done with Angular2 first App setup.

13. To do small test, just open <projectName>/src/app/app.component.ts

          Add below message to the title

          sample-change-to-app-component

14. Once you save the file then you will immediate see the change without refresh the page.

         change-preview

15. Last and most important step to build your project for production.

production-build

After running above command, there is a new dir “dist” created and inside this, there are flat html and js file to deploy in production to have complete angular2 app.

build-dir

Final files for production deployment

build-dir-overview

This blog explained the basics of to start angular2 project and release final build for production.

I hope this will help you move further.

Happy learning with Angular2

 

share or like this post
Share

Leave a Reply

Your email address will not be published. Required fields are marked *

Share