launch.json
{ //chromium --remote-debugging-port=9222 --user-data-dir=remote-debug-profile > /dev/null --disable-web-security & "type": "chrome", "request": "attach", "name": "attach to browser", "port": 9222, "url":"http://localhost:4200", "webRoot": "${workspaceFolder}/src" }
{{data.exampleDate | date:"MM/dd/yy"}} or {data.exampleNum | fixedVal:42}}
. Chaining is possible {{data.exampleDate | date | uppercase}}
<li *ngFor="let obj of objcts"> <p>blah</p> </li>
<div *ngIf="objcts.length > 0"> <p>blah</p> </div>
<div *ngIf="objcts.length > 0; else example"> <ul> <li *ngFor="let obj of objcts"> <p>blah</p> </li> </ul> </div> <ng-template #example> <div> <p>Nothing to display</p> </div> </ng-template>
<div [ngSwitch]="data.val"> <div *ngSwitchCase="1">1</div> <div *ngSwitchCase="2">2</div> <div *ngSwitchCase="3">3</div> <div *ngSwitchCase="4">4</div> <div *ngSwitchCase="5">5</div> <div *ngSwitchDefault>No value</div> </div>
<app-example [data]="obj"></app-example>
and in example.component.ts
@Input() data:Obj = {...};
export class ExampleComponent implements OnInit { constructor(objService:ObjService) { this.obj = objService.getObj(); } }
import { Pipe, PipeTransform } from '@angular/core'; @Pipe({name:'examplePipe'}) //that does no transformation export class TruncatePipe implements PipeTransform { transform(): string { return value; } }
npm install -g @angular/cli ng new <project_name>
ng help ng serve: Serve Angular project using a development server