Angular2 Basic


Angular 2 - Basic:

ng version // verify that Angular CLI is installed
ng new applicationName // create a new application
cd applicationName
ng serve  // Starts the development server
  // Open your browser to http://localhost:4200/
  // Maybe this is for serving the index.html in a browser and 
  // refreshes the browser when application files change.

ng g component componentName // generate a new component
ng g directive directiveName // generate a new directive
ng g pipe pipeName // generate a new pipe
ng g service serviceName // generate a new service
ng g class my-new-class // generate a new class

ng g interface interfaceName // generate a new interface
ng g enum enumName

ng test // run unit tests
ng e2e // run end-to-end tests
ng lint // 

Quickstart Guide:

 1. Install npm
 2. mkdir angular-quickstart
 3. cd angular-quickstart
 4. create the package.json file as mentioned on
 5. npm install
 6. mkdir app (We like to keep our application code in 
    a sub-folder off the root called app)
 7. cd app
 8. Add the component file named app.component.js as indicated on
 9. Add an NgModule file named app/app.module.js as indicated on
10. Add a new file , main.js, to the app/ folder as indicated on
11. Add the index.html as indicated on
12. Create the style.css in the same folder as the index.html file.
13. npm start

The 'npm start' command does the following:

1. Runs the TypeScript compiler in watch mode
2. Starts the server
3. Launch the app in a browser
4. Keep the app running while we continue to build our app.
Unless otherwise stated, the content of this page is licensed under Creative Commons Attribution-ShareAlike 3.0 License