Krzysztof Michalski
Krzysztof Michalski

Reputation: 831

Passing parameter to function in ng-repeat by ng-click

Hi I have a problem with passing in ng-repeat parameters in function by ng-click. My tr in ng-repeat is:

<tr ng-repeat="generalSurvey in surveys">
    <td>
       <% generalSurvey.survey.trans_id %>
    </td>
    <td>
       <% generalSurvey.survey.created_at | date:'yyyy-MM-dd HH:mm:ss' %>
    </td>
    <td>
       <% generalSurvey.save_answers_date | date:'yyyy-MM-dd HH:mm:ss' %>
    </td>
    <td>
       <% generalSurvey.survey.base_survey.name %>
    </td>
    <td>
       <% generalSurvey.survey.status.name %>
    </td>
    <td>
       <div ng-click = "editCase( {{ generalSurvey.caseData.caseId  }} )"><% generalSurvey.caseData.caseId %></div>
    </td>
    <td>
       <% generalSurvey.caseData.firstContact %>
    </td>
</tr>

Below I show code of my directive:

link: function (scope, element, attrs) {
    scope.surveys = {};

    scope.getSurveys = function () {
        surveysClient.getAll(function (callback) {
            scope.surveys = callback.data;
            console.log(scope.surveys);
        });
    };
    // Pobranie danych o ankietach
    scope.getSurveys();
    scope.editCase = function (selectedCase) {
       CicCase.get(parseInt(selectedCase), function (callback) {
            console.log("siema");
       });
    }
},

Error which I I'm seeing now is: enter image description here

How could I pass this param correctly?

Upvotes: 0

Views: 1355

Answers (1)

Ankit Agarwal
Ankit Agarwal

Reputation: 30739

The ng-click for

ng-click = "editCase( {{ generalSurvey.caseData.caseId  }} )"

should be written as

ng-click = "editCase( generalSurvey.caseData.caseId )"

With no expression syntax {{}}

Upvotes: 3

Related Questions