2

I'm developing an app and I've a table populated with ng-repeat and the last column of the table is an image that it is clicked open another page that should contains more details about the line of the table that I've choose clicking the image.

I've tried to use an input type hidden in a form but it doesn't work for me.

This is my code:

<tr ng-repeat="Data in response">
                    <td align="center">{{Data.date}}</td>
                    <td align="center">{{Data.conf}}</td>
                    <td align="center">{{Data.evaso}}</td>
                    <form ng-submit="submit()">
                        <input type="hidden" name="codice" value="Data.code" ng-model="codice">
                        <td align="center"><input type="image" src="img/note.png" class="imageNote" ng-click="submit()"></td>
                    </form>
                </tr>

After in the controller I need to manage this data (the cod). But in this way, I've tried to print it in the console and the result is undefined.

How can I solve this problem?

4
  • Does the type=image call the submit function? You should check that. Your function should $scope.submit Commented Dec 19, 2016 at 10:43
  • yes the image call the submit function correctly @Kermani Commented Dec 19, 2016 at 10:48
  • Your codice variable will save the same data as Data.code. In other terms codice = Data.code? Commented Dec 19, 2016 at 10:48
  • You want to have the selected item in your submit, right? Then my answer should work! But if you needed something else, please let me know maybe I am just confused Commented Dec 19, 2016 at 10:53

2 Answers 2

0

I am not sure if I get your question, but if you want to pass the selected item to the submit function, you can have your angular function like this:

$scope.submit = function(selectedId){
   console.log(selectedId);
   //Your code.
}

and your HTML should change to this:

<input ng-click="submit(Data.id)" type="image" src="img/note.png" class="imageNote">

Note: You do not need to use {{}} (expressions) to pass something to a function (here, ng-click)

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

Comments

0

I think you can try following way to get easily the Date.code data on click:

<input type="image" src="img/note.png" class="imageNote" ng-click="submit(Data.code)">

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.