{{var}}
Two-way binding. "Banana in a box". All variables that refer to the hero.name
will be updated , too.
[()]
[(ngModel)]="hero.name"
from inside:
<input [(ngModel)]="hero.name" placeholder="name">
value="{{hero.name}}"
<input value="{{hero.name}}" placeholder="name">
Special Angular HTML element. For example,
[(ngModel)]="hero.name"
<li *ngFor="let localHero of heroes">
<span class="badge">{{localHero.id}}</span> {{localHero.name}}
</li>
*ngFor
= this class and its children is the master templatelet localHero of heroes
localHero
= local variable ofheroes
array- it is similar to this in java
for(Hero localHero: heroes) {
//do something
}
(click)=onSelect(hero)
(click)
is click eventonSelect(hero)
is a method that this event is binded.
[class.selected]="hero === selectedHero"
[class.selected]
is a property- It changes class to
[class.selected]
whenhero === selectedHero
hero === selectedHero
--> true- when its class changes, the property changes accordingly.
<my-hero-detail [hero]="selectedHero"></my-hero-detail>
[hero]
is a property binding. This hero
variable is assigned with the selectedHero
variable.
<div *ngIf="selectedHero">
<h2>{{selectedHero.name}} details!</h2>
</div>
Hide itself and its child if variable is null. If selectedHero is null. Then don't show div and its sibling.
@Input()
hero: Hero;
@Input()
to annotate that this variable is passed from another component.