To Install Angular CLI
Npn install –g @angular/cli@latest
Ng version will give you version
Install Angular Project
Ng new project_folder_name
To Start Angular Web Service
Ng serve
Generate a new component
ng generate component component_name
short version
ng g c component_name
Define a route
Go to app-routing.modules.ts
Import component
import { HomeComponent } from './home/home.component';
define path
const routes: Routes = [
{ path : "", component : HomeComponent}
];
Event Binding
Write event in a component html
<button (click)="justClick()">Click Me</button>
Define event/method in component’s ts file in class
justClick(){
console.log("hello world");
}
Dynamic Values
In HTML file
<a routerLink="/" class="logo">{{ appTitle }}</a>
In class
appTitle : string = "wishdd";
Add components to Main HTML
Use selector from component class and use it as wrapper
From class
selector: 'app-nav',
in app.component.html
<app-nav></app-nav>