DEV Community

RahulPatil72225
RahulPatil72225

Posted on

1

How to call a function on edit button in angular?

My project angular version:

Angular CLI: 9.0.0-rc.7

I m working with grid and I want to edit a record. and I call a function on edit Button then console.log is not display on the browser??

partymastercomponent.ts

import { Component, OnInit } from '@angular/core';
import { BackendService } from '../backend.service';

@Component({
selector: 'app-partymaster',
templateUrl: './partymaster.component.html',
styleUrls: ['./partymaster.component.css']
})
export class PartymasterComponent implements OnInit {

PartyMstId: any;
PartyCode: any;
PartyName: any;

partylist: any;

constructor(public myservice: BackendService) { }

columnDefs = [
  {
      headerName: "Edit",
      field: "icon",
      width: 100,
      //id: this.PartyMstId,
      cellRenderer: function (params)
      {
                    //return  '<button (click)="editfunction()"><i class="fa fa-edit"></i></button>' //when i press edit icon then console log not print
                     return '<button (click)="editfunction()" >ClickThis</button>' //when I press button then console.log is not display
      }
  },
  { headerName: 'PartyMstId', field: 'PartyMstId', sortable: true, filter: true/*, checkboxSelection: true*/ },
  { headerName: 'PartyCode', field: 'PartyCode', sortable: true, filter: true },
  { headerName: 'PartyName', field: 'PartyName', sortable: true, filter: true },

];

editfunction() {
console.log("call this edit function");
}
}

partymastercomponent.html

class="ag-theme-balham"
[rowData]="partylist"
rowSelection="multiple"
[columnDefs]="columnDefs">

how to call a function on edit button click??

icon as well as button is not working??

when I press write click on browser then

browser

please help?

Hostinger image

Get n8n VPS hosting 3x cheaper than a cloud solution

Get fast, easy, secure n8n VPS hosting from $4.99/mo at Hostinger. Automate any workflow using a pre-installed n8n application and no-code customization.

Start now

Top comments (2)

Collapse
 
devpato profile image
Pato

Can you create an stackbliz please

Collapse
 
rahulpatil72225 profile image
RahulPatil72225

but stackbliz give an error Still I m facing this problem?

Some comments may only be visible to logged-in visitors. Sign in to view all comments.

A Workflow Copilot. Tailored to You.

Pieces.app image

Our desktop app, with its intelligent copilot, streamlines coding by generating snippets, extracting code from screenshots, and accelerating problem-solving.

Read the docs

👋 Kindness is contagious

Engage with a wealth of insights in this thoughtful article, valued within the supportive DEV Community. Coders of every background are welcome to join in and add to our collective wisdom.

A sincere "thank you" often brightens someone’s day. Share your gratitude in the comments below!

On DEV, the act of sharing knowledge eases our journey and fortifies our community ties. Found value in this? A quick thank you to the author can make a significant impact.

Okay