사용자 도구

사이트 도구


angular:event-binding

Event Binding

import { Component, OnInit } from '@angular/core';
 
@Component({
  selector: 'app-test-eb',
  template: `
  <h2>
    Welcome {{ name }}
  </h2>
  <button (click)="onClick($event)">Greet</button>
  <button (click)="greeting='Welcome Code'">Greet</button>
 
  {{ greeting }}
  `,
  styleUrls: ['./test-eb.component.css']
})
export class TestEbComponent implements OnInit {
  name = "Codevolution";
  greeting = "";
  constructor() { }
 
  ngOnInit() {
  }
 
  onClick(event){
    console.log(event);
    this.greeting = event.type;
  }
}
angular/event-binding.txt · 마지막으로 수정됨: 2025/04/15 10:05 저자 127.0.0.1