Skip to content

Conversation

@davitenium
Copy link

No description provided.

<br>

<button type="button" class="buy-socks" (click)="buy()">
<button id="buyBtn" *ngIf="sock.inventory > 0" type="button" class="buy-socks" (click)="buy()">
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Avoid <HTMLInputElement> document.getElementById("buyBtn"); --> it's mixing together pure JavaScript & Angular.

In this case you could use:

 <button [disabled]="buttonDisabled" *ngIf="sock.inventory > 0" type="button" class="buy-socks" (click)="buy()">

If you really need to manipulate a DOM object manually (this should be rare)

constructor(elementRef: ElementRef) {}

See: https://angular.dev/guide/components/dom-apis#

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants