AngularJS with md.data.table handler?

0

I have an app with AngularJS using Material Design and md.data.table in the latest version of each Framework (respectively 1.6.4, 1.1 .0 and 0.10.x). In the documentation for md.data.table you can verify that there is a callback function when an item in the table is selected. However,whenusingthisfunctioninmyscripts,italwayshappensthatthisfunctionisnevercalledonce.Itisinvokedwhenthetableisloaded,whenIselectanitem(whichwasonlyforONEtime,butittriggers150simultaneouscallswhich,formycode,shouldnothappen),IhavealreadytriedtoworkaroundthisproblemandIdecidedtoaskforhelp.BelowisatestthatIdidwithaconsolelog.

Code

vm.onMainFlowSelected=(flow)=>{console.log('executado');}

PrintScren

ThescreenhasjustloadedandNOTHINGisselected,however

Console

Theywereexecuted80times,onlyonpageload.

Justsoasnottobeindoubt,hereismydirectiveat AngularJS

<tr 
md-row md-select="flow" 
md-select-id="flow.id" 
md-auto-select 
md-on-select="onSelectItem(flow)">
    
asked by anonymous 26.05.2017 / 21:03

1 answer

0

I discovered what it was.

In

<tr 
md-row md-select="flow" 
md-select-id="flow.id" 
md-auto-select 
md-on-select="onSelectItem(flow)">

When I pass the function to the view, it takes reference and I was using () when in fact I should just pass the method. So, to solve I need only remove the () from the md-on-select tag, thus:

<tr 
md-row md-select="flow" 
md-select-id="flow.id" 
md-auto-select 
md-on-select="onSelectItem">

Thank you.

    
26.05.2017 / 21:52