Skip to content

sending a arrayIndex as a parameter to onclick button function #568

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
franklopez opened this issue Oct 5, 2015 · 9 comments
Closed

sending a arrayIndex as a parameter to onclick button function #568

franklopez opened this issue Oct 5, 2015 · 9 comments

Comments

@franklopez
Copy link

Hi I have this issue:

form:
{
"type": "button",
"htmlClass" : "bt-down",
"onClick" : "showCountries(arrayIndex)",
"icon": "fa fa-search"
}

this in inside an array, and i want to call showCountries(arrayIndex) and have the index array value in my function how can i do this?

regards,

Francisco Lopes

@Anthropic
Copy link
Member

Have you tried $index? I know that is available for a tabarray, I would assume it is for any array, but haven't checked.

@franklopez
Copy link
Author

nope it doesn't work either the value comes undefined to the function:

$scope.showCountries = function(index) {

@Anthropic
Copy link
Member

Can you provide a more detailed example of what you are doing, like a plunker or something similar? May help to see where the problem is.

@vinceis1337
Copy link

@Anthropic I can give an example:

I want to open a website based on the input in the form.
If the user enters in the text field "www.reddit.com" I want to launch a onClick method launchWebsite(url);
However, this is in an array so my onClick method looks like:
launchWebsite(model.websites[indexArray].url);

indexArray returns as undefined in the onClick method though.
If I put "condition": "model.websites[indexArray].url" this works fine for hiding or showing the button, for example. But the onClick method does not understand indexArray.

Additionally, $index and index are both undefined for onClick on both array and tabarray types. So that didn't work either.

I'm hoping @davidlgj or another expert might be able to chime in on this?

@Anthropic Anthropic self-assigned this Apr 11, 2016
@Anthropic Anthropic added this to the 1.0.0 milestone Apr 11, 2016
@Anthropic
Copy link
Member

Thanks @franklopez @vinceis1337 I will look into it, I have added this to a copy locally and so far so good, I am hoping it can be done as part of PR #652

@coxrichuk
Copy link

Has anyone had any success with passing the arrayindex / $index as a parameter to a function?

@Anthropic
Copy link
Member

@coxrichuk it is partially working in the webpack branch but at the same time it has other things broken. But you could certainly take a look there for ideas on how it was fixed, but there are also other questions asked in issues that also provide further info on how it can be overcome.

@Anthropic
Copy link
Member

This works in the alphas for v1.0.0, you can pass whatever($index)

@vinceis1337
Copy link

Excited to see this functionality in 1.0.0!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants