npm install -g angular-cli
ng help
ng new PROJECT_NAME
cd PROJECT_NAME
ng serve --host 192.168.1.75 --port 3000
ng generate component my-new-component
ng generate component my-new-component/item
[ --flat(no create subfolder) | --it (inline template) | --is (inline style) ]
<p>{{ serverId }}</p>
<p>{{ getServerId() }}</p>
<button [disable]="isEditMode"></button>
<button (click)="onSelect()"></button>
onSelect(){
...
}
Pass event data
<input (input)="onInputText($event)"></input>
onInputText(event:Event){
...
}
Set a value on controller
<button (click)="userName='Pablo'"></button>
<button (onChangeName)="userName=$event"></button> //set data from with an event emitted from a child component
serverName = "myServer"; //prepopulate input value from controller
<input [(ngModel)]="serverName"></input>
<p>{{serverName}}
(<HTMLInputElement>event.target).value
ngIf
<p *ngIf="isEditMode"></p> //It's not just hidden, it doesn't exist on the DOM
ngIf;else (angular4)
<div *ngIf=”condition; else elseBlock”>Truthy condition</div>
<ng-template #elseBlock>Falsy condition</ng-template>
ngStyle
<p [ngStyle]="{'background-color:getColor()}"></p>//binding to a property of the directive
getColor(){
return this.completed === true ? 'green':'red';
}
ngClass
<p [ngClass]="{class:variable === 'value'}"></p>
ngFor
<ul>
<li *ngFor="let element of array; let i = index">
{{element}}{{i}}
</li>
</ul>
<presupuesto-item *ngFor="let presupuesto of presupuestoList" [presupuesto]="presupuesto">
ngContent
//parent componet
<child-component>
content from parent //this content will be pass to ng-content directive in the child component
</child-component>
//child component
<div>
<ng-content></ng-content>
</div>