사용자 도구

사이트 도구


angular:template-reference-variables

Template Reference Variables

myInput을 주의해서 보시면 되겠습니다.

import { Component, OnInit } from '@angular/core';
 
@Component({
  selector: 'app-test-trv',
  template: `
  <h2>
    Welcome {{ name }}
  </h2>
  <input #myInput type="text">
  <button (click)="logMessage(myInput)">Log</button>
  `,
  styleUrls: ['./test-trv.component.css']
})
export class TestTrvComponent implements OnInit {
  name = "Codevolution";
 
  constructor() { }
 
  ngOnInit() {
  }
 
  logMessage(value){
    console.log(value);
  }
}
angular/template-reference-variables.txt · 마지막으로 수정됨: 2025/04/15 10:05 저자 127.0.0.1