0

I've just started out using Ionic, I am trying to print the value of the selected list Item {{ item.value }} , however can't find any documentation that suggests how to do this.

Possibly an ng-click="myFunction()" would work here, but I am stuck as to where to start. I have it working with the Ionic Radio buttons. But I want the list to re-direct to another page on click, but still hold this value in the main controller.

Here is the Codepen attempt.

Thank you.

1 Answer 1

0

Well, at first ng-click="do" will do absolutely nothing. It should be ng-click="do()", and of course, you have to have a function called do in your controller to perform an action.

The 2nd. problem is: you're inside ngRepeat, it creates a child $scope, so you have to use the Dot Rule:

$scope.model = {};

Then, you can do it:

ng-click="model.itemValue = item"

Check the forked DEMO

3
  • Thanks so much. I was getting so confused, but it's very clear now. If I wanted only the value, not the JSON, I would do 'ng-click="model.itemValue = item.value'?
    – o1n3n21
    Aug 7, 2016 at 17:46
  • @nick_1002 yes. Can you check it as answer? Aug 7, 2016 at 17:49
  • I'm glad that this has helped :) Aug 7, 2016 at 17:51

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.