This project was generated with Angular CLI version 7.3.8.
Run ng serve
for a dev server. Navigate to http://localhost:4200/
. The app will automatically reload if you change any of the source files.
Run ng generate component component-name
to generate a new component. You can also use ng generate directive|pipe|service|class|guard|interface|enum|module
.
Run ng build
to build the project. The build artifacts will be stored in the dist/
directory. Use the --prod
flag for a production build.
Run ng test
to execute the unit tests via Karma.
Run ng e2e
to execute the end-to-end tests via Protractor.
To get more help on the Angular CLI use ng help
or go check out the Angular CLI README.
<button class="btn btn-primary" [disabled]="!isAddServerBtnDisabled" (click)="onCreateServer()">Add Server</button>
<p>{{ severCreationStatus }}</p>
-
Property binding: **
[disabled]="!isAddServerBtnDisabled"
-- use[]
brackets **{{ severCreationStatus }}
-- String interpolation -
Event binding: **
(click)="onCreateServer()">
-- use()
brackets -
Two way binding **
[()]
-- property and event -
Directives
ngIf
<p *ngIf="serverCreated; else noServer">Server was created with name : {{ serverName }}</p>
<ng-template #noServer>
<p>No server was created!</p>
</ng-template>
ngFor
<p *ngFor="let current of currents; let i = index">
1. currents is a variable (list) in the component
2. current will be looped object.
3. index is angular variable holding index of the loop.
4. i can be furhter used in ngStyle or ngClass
Loading the style as per condition in the function.
<p [ngStyle]="{ backgroundColor: getColor() }">
Loading the css class as per condition in the function.
<p [ngClass]="{ online: getServerStatus() === 'online' }">