How to add a custom button with event emmeter ?
See original GitHub issueHey,
I’d like to add a custom button on each row. I achieved it dealing with the ‘html’ property and the sanitizer, but I couldn’t find a way to handle the event ? Is it possible to add an event emitter which is correctly interpreted by ng2? Bypassing HTML & JS Security ?
I can’t listen directly to the button events.
What I’m currently doing:
{
columns: {
test: {
title: 'fire',
type: 'html',
valuePrepareFunction: (value) => {
return this._sanitizer.bypassSecurityTrustHtml('<button (click)="test()">TEST</button>'); //Click listener not interpreted...
}
}
}
};
Then add an event on the table
<ng2-smart-table [...] (userRowSelect)="onSelect($event)"></ng2-smart-table>
Set the selected item
onSelect(event){
this.selectedItem=event.data._id;
}
Then add an outside button to the table that handle the wanted event.
Thanks
Issue Analytics
- State:
- Created 7 years ago
- Reactions:4
- Comments:10
Top Results From Across the Web
How to build custom Node.js event emitters - LogRocket Blog
Create the event emitter function constructor; Add methods to the event ... Custom events occur inside the JavaScript core in Node.js.
Read more >How to create and fire a custom event in angular
You declare a class property with the @Output() decorator and instantiate it to a new EventEmitter instance. Example from the Angular docs
Read more >How to Custom event Emitter in Angular Calendar component
The two-way binding in Calendar can also be achieved using the custom event binding and property binding in the controls present in two...
Read more >EventEmitter - Angular
Use in components with the @Output directive to emit custom events synchronously or asynchronously, and register handlers for those events by subscribing to ......
Read more >Understanding Event Emitters | CSS-Tricks
We added a listener to a button click. We've subscribed to an event being emitted and we fire a callback when it does....
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Well it’s a way to avoid the current problem, sorry if it didn’t fit you needs.
I didn’t solve this issue, I just took one existing button (like the Edit button), and override the behavior by setting the table mode to ‘external’ and using the event.