Reputation: 287
I want to create a button in typescript file using the html tags.I don't know how to add click event for that button i have created 2 action buttons wat to add the click event
"data": "img", "render": function (data) {
return '<button class="btn tblActnBtn" value= "Click" id="edit" (click)="onClickMe()" ><i class="material-icons">mode_edit</i></button><button class="btn tblActnBtn"><i class="material-icons">delete</i></button>'
}
Thanks,
Upvotes: 2
Views: 10020
Reputation: 287
self.testTable.on('click', 'input', function () {
var tr = $(this).closest('tr');
var row = self.testTable.row(tr);
var id = this.id;
var data = self.testTable.row(tr).data();
if (id == 'check') {
console.log("****",row.data())
}
});
It works for me.
Upvotes: 0
Reputation: 299
html :
<div [innerHTML]="answerPanelContent"></div>
ts:
import { Component, Renderer2, ElementRef, OnInit } from '@angular/core';
@Component({
selector: 'my-app',
templateUrl: './app.component.html',
styleUrls: [ './app.component.css' ]
})
export class AppComponent implements OnInit {
constructor( private renderer:Renderer2,
private el:ElementRef) { }
ngOnInit() {
const button = this.renderer.createElement('button');
const buttonText = this.renderer.createText('Click me');
this.renderer.appendChild(button, buttonText);
this.renderer.appendChild(this.el.nativeElement, button);
this.renderer.listen(button, 'click', () => {alert('hi');});
}
}
you can write every event in {alert('hi');......}
Upvotes: 1