Tartalomjegyzék

< Angular

Angular Elemek rejtése

[hidden]

src/app/app.component.html
<h1>Rejtés</h1>
 
<button (click)="showDiv()">Mutat</button>
<br>
 
<div [hidden]="!edited">Eredmény: {{result}}</div>
src/app/app.component.ts
import { Component } from '@angular/core';
 
@Component({
  selector: 'app-root',
  templateUrl: './app.component.html',
  styleUrls: ['./app.component.css']
})
export class AppComponent {
  title = 'app23';
  result = 30;
  edited = false;
  showDiv() {
    this.edited = true;
  }
}

*ngIf

Elavult az Angular 17-ben!
src/app/app.component.html
<h1>Rejtés</h1>
 
<button (click)="showDiv()">Mutat</button>
<br>
 
<div *ngIf="edited">Eredmény: {{result}}</div>
src/app/app.component.ts
import { Component } from '@angular/core';
 
@Component({
  selector: 'app-root',
  templateUrl: './app.component.html',
  styleUrls: ['./app.component.css']
})
export class AppComponent {
  title = 'app23';
  result = 30;
  edited = false;
  showDiv() {
    this.edited = true;
  }
}