Angularjs with Md.data.table Handler?

Asked

Viewed 76 times

0

I have an app with Angularjs using Material Design and Md.datatable. in the latest version of each Framework(respectively 1.6.4, 1.1.0 and 0.10.x). In the Md.datatable. it is possible to verify that there is a callback function when a table item is selected.inserir a descrição da imagem aqui However, when using this function in my scripts, it always happens that this function is never called only once. It is invoked when the table is loaded, when I select an item (which was only supposed to occur ONCE, but it triggers 150 simultaneous calls, which, for my code, should not happen), I tried to get around this problem and decided to ask for help. Below is a test I did with a console log.

Code

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

Print Scren

The screen has just uploaded and NOTHING is selected, however inserir a descrição da imagem aqui

Console

inserir a descrição da imagem aqui

They were executed 80 times, only at page loading.

Just so there’s no doubt, here’s my directive on Angularjs

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

1 answer

0


I found out 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 picks it up in reference and I was using it () when actually I should just pass the method. Therefore, to solve I need only remove the () from the Md-on-select tag, thus staying:

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

Thanks.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.