web-dave / angular_workshop

0 stars 0 forks source link

Create a Directive #12

Open web-dave opened 2 months ago

web-dave commented 2 months ago

  @Input() orderBtn: string = '';

  orderBtnElement: HTMLButtonElement = document.createElement('button')

  elementRef = inject(ElementRef);

  ngOnChanges(){
    this.orderBtnElement.innerText = this.orderBtn,
  }

  constructor() {
    elementRef.nativeElement.appendChild(this.orderBtnElement);
    fromEvent(this.orderBtnElement, 'click')
     .subscribe(() =>console.log('this.orderBtn:', this.orderBtn))
  }

web-dave commented 2 months ago

NEXT