angular-basic-elements Flashcards
Structural directives
Those are responsible for the page layout. Just like media in html. Structural directives: NgIf, NgFor, NgSwitch.
Dependency injection
Design pattern which requires instance of class rather than create it.
Routing
Single page applications with navigation for changing views. Application need to have 2 componets at least. And module for routing.
Guard Rouing
It checks if the user have the permission to acces the module
CLI command in angular to create new component
ng g c name-of-component
NgClass directive what for is used ?
We can add html element classes by using NgClass directive: ----- html ----- PressME ----- ts ----- elementClasses= { dimmed : true, special : false, hidden : true }
button will belong to classes: dimmed, hidden
NgStyle what for is used?
NgStyle is used for manipulating styles of the element, the syntax is similar to the NgClass.
NgModel what is used for ?
Ng model allows us to change data in the html elements, the syntax is more complex, because we need to make [(ngModel)]
ngIf
*ngIf = “isActive”
directive ngIf allows to show element if the variable is true
ngFor
*ngFor = “let item of items”
ng for allows to get acces for iterative element in some set using elementwise for.
ngSwitch case
the name tell us what it does, but the syntax is ugly
<div>
‹div *ngSwitchCase="'Bob'"›Hi dad</div>
<div>Hi Mom
<div>Hi friend</div></div>
How to make routing?
- make app-routing.module
- import router in app routing module
- define routes in module
- set the imports, exports
- use the routerLink
- use
How to pass data during routing?
By ActivatedRouter