Below steps might help you to start your first project in Angular. Nicely explained here
Go to https://nodejs.org/en/download/ and select npm version based on your OS (Windows or Mac)
To check npm is installed, run npm -v
. it will give you installed npm version.
Another commands to install latest npm
npm install -g @angular/cli
To check available CLI commands type this.
Now you can use below commands to Create New Angular 4 Project
ng new first-project
It will create Angular project first-app and will install required npm packages.
To start project, you can use
ng serve
To create Angular 4 Component
ng g component cities
How to create Router for The Newly Component
To make access the new component, we have to make routing for it. Open and edit src/app/app.module.ts the add this import.
import { RouterModule } from '@angular/router';
imports: [ BrowserModule, FormsModule, HttpModule, RouterModule.forRoot([ { path: '', redirectTo: 'newComponentName'},
{ path: 'componentname', component: ComponentName } ])
]
Next, replace all tags in src/app/app.component.html with this tag.
<router-outlet></router-outlet>