oktatas:web:angular:angular_animacio
Különbségek
A kiválasztott változat és az aktuális verzió közötti különbségek a következők.
Előző változat mindkét oldalonElőző változatKövetkező változat | Előző változat | ||
oktatas:web:angular:angular_animacio [2025/07/16 23:38] – [Angular - Animáció] admin | oktatas:web:angular:angular_animacio [2025/07/17 00:09] (aktuális) – [Háromszög terület számítás eredménye] admin | ||
---|---|---|---|
Sor 132: | Sor 132: | ||
===== Háromszög terület számítás eredménye ===== | ===== Háromszög terület számítás eredménye ===== | ||
+ | |||
+ | <code javascript src/ | ||
+ | import { ApplicationConfig, | ||
+ | import { provideRouter } from ' | ||
+ | |||
+ | import { routes } from ' | ||
+ | import { provideAnimationsAsync } from ' | ||
+ | |||
+ | export const appConfig: ApplicationConfig = { | ||
+ | providers: [ | ||
+ | provideZoneChangeDetection({ eventCoalescing: | ||
+ | provideRouter(routes), | ||
+ | provideAnimationsAsync() | ||
+ | ] | ||
+ | }; | ||
+ | |||
+ | </ | ||
Szeretnénk az eredményt animáltan megjeleníteni. | Szeretnénk az eredményt animáltan megjeleníteni. | ||
<code javascript src/ | <code javascript src/ | ||
- | import { animate, state, style, transition, trigger | + | import { Component |
- | import { Component, OnInit | + | import { |
- | import { FormControl | + | animate, |
+ | state, | ||
+ | style, | ||
+ | transition, | ||
+ | trigger | ||
+ | } from ' | ||
+ | import { FormBuilder, | ||
@Component({ | @Component({ | ||
selector: ' | selector: ' | ||
- | | + | |
- | | + | |
animations: [ | animations: [ | ||
trigger(' | trigger(' | ||
state(' | state(' | ||
- | backgroundColor: | + | backgroundColor: |
})), | })), | ||
state(' | state(' | ||
Sor 158: | Sor 181: | ||
animate(' | animate(' | ||
]) | ]) | ||
- | ]) | + | ]) |
- | ] | + | ], |
+ | |||
+ | templateUrl: | ||
+ | styleUrl: ' | ||
}) | }) | ||
- | export class TriangleComponent | + | export class TriangleComponent { |
- | base = new FormControl('' | + | |
- | height = new FormControl('' | + | |
- | area = new FormControl('' | + | |
- | isVisible = false; | + | |
- | constructor() { } | + | |
- | | + | |
- | | + | |
+ | triangleForm = this.builder.group({ | ||
+ | base: '', | ||
+ | height: '', | ||
+ | area: '' | ||
+ | }) | ||
+ | |||
+ | isVisible = false; | ||
+ | |||
onCalcButtonClick() { | onCalcButtonClick() { | ||
this.isVisible = true; | this.isVisible = true; | ||
- | let area = this.calcTriangleArea(this.base.value, this.height.value); | + | let area = this.calcTriangleArea( |
- | this.area.setValue(area); | + | Number(this.triangleForm.value.base), |
+ | Number(this.triangleForm.value.height) | ||
+ | | ||
+ | this.triangleForm.patchValue({area: String(area)}); | ||
} | } | ||
onDeleteButtonClick() { | onDeleteButtonClick() { | ||
this.isVisible = false; | this.isVisible = false; | ||
- | this.base.setValue('' | + | this.triangleForm.reset(); |
- | this.height.setValue('' | + | |
- | this.area.setValue('' | + | |
} | } | ||
calcTriangleArea(base: | calcTriangleArea(base: | ||
Sor 186: | Sor 215: | ||
} | } | ||
} | } | ||
+ | |||
</ | </ | ||
<code html src/ | <code html src/ | ||
+ | <form class=" | ||
+ | <div class=" | ||
+ | <label for=" | ||
+ | class=" | ||
+ | <input type=" | ||
+ | id=" | ||
+ | </ | ||
+ | <div class=" | ||
+ | <label for=" | ||
+ | class=" | ||
+ | <input type=" | ||
+ | id=" | ||
+ | </ | ||
- | <div class=" | + | |
- | <div class=" | + | <button class=" |
- | <label for=" | + | <button class=" |
- | class=" | + | </ |
- | <input type=" | + | |
- | id=" | + | |
- | </ | + | |
- | <div class=" | + | |
- | <label for=" | + | |
- | class=" | + | |
- | <input type=" | + | |
- | id=" | + | |
- | </ | + | |
- | + | ||
- | | + | |
- | <button class=" | + | |
- | <button class=" | + | |
- | </ | + | |
- | + | ||
- | <div class=" | + | |
- | <label for=" | + | |
- | class=" | + | |
- | <input type=" | + | |
- | id=" | + | |
- | </ | + | |
- | </ | + | |
+ | <div class=" | ||
+ | <label for=" | ||
+ | class=" | ||
+ | <input type=" | ||
+ | id=" | ||
+ | </ | ||
+ | </ | ||
</ | </ | ||
oktatas/web/angular/angular_animacio.1752701911.txt.gz · Utolsó módosítás: 2025/07/16 23:38 szerkesztette: admin