Reputation: 2954
I need to convert the following jquery codes to typescript code.
Jquery
$(".room").click({
console.log("clicked");
});
TypeScript
import { Component } from '@angular/core';
declare var $: any;
export class AppComponent {
}
Upvotes: 1
Views: 3568
Reputation: 2225
On your element that has room class in HTML you can do something like this in your component template:
For example if your element is a button:
<button class="room" #btn (click)="buttonClick()">Click Me!</button>
And then in your class:
import { Component } from '@angular/core';
declare var $: any;
export class AppComponent {
buttonClick(){
console.log("Button Clicked!");
}
}
Hope this helps :)
Upvotes: 3