1

This answer helped me understand how to bound a variable via ng-click: How can you pass a bound variable to an ng-click function?

However, what if the variable that needs to be passed is a nested variable?

For example:

The nested variable: {{item['id']['attributes']['im:id']}}

How would this be called inside of ng-click?

<a ng-click="open('item['id']['attributes']['im:id']')"> 

Definitely does not work because of the multliple use of the single quote.

Thanks!

__ Edit ___

Attached is the JSFiddle of what I am trying to achieve: http://jsfiddle.net/RUnaE/4/

Basically in $scope.test, the value that I am trying to pass within ng-click to the contoller is {{ item['id']['attributes']['im:id']}}

2
  • please post your json structure and will be better to show your issue in Fiddle or PLunker, thanks Commented Oct 6, 2013 at 20:40
  • Thanks for the tip. I'll get a Plnker up ASAP for the issue. Commented Oct 6, 2013 at 20:46

1 Answer 1

1

For reference, I believe this is the correct solution to the question I asked above: Here is a JSFiddle for future reference: http://jsfiddle.net/RUnaE/6/

ng-click="open(item.id.attributes['im:id'])"

The non-proper variable is placed within enclosing brackets.

Hope this will help future searchers.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.