0

Hello I am having trouble when passing a parameter to a function called addToHistory(param). When I try to write to the console it just says undefined, but when I try to pass a number it gets correctly displayed on the console.

  $scope.addToHistory = function(title) 
     {

      console.log(" " + title);  //<-- is undefined

         $scope.tasksHistory.push({
        info: title,
        measured: "measured",
        total: "total",
        done: 0,
        id: 2
         });

     };


 <ion-item ng-repeat="task in tasksCollection" ng-controller="HistoryCtrl" ng-click="addToHistory({{task.info}})" href="#/app/history/{{task.id}}">
            {{task.info}} 
           <!--  <i class="icon ion-plus icon-right" ></i> -->
 </ion-item>
1
  • 3
    addToHistory(task.info), without curly brackets. Commented May 14, 2015 at 2:56

1 Answer 1

3
ng-click="addToHistory(task.info)"

Remove the brackets in the function call

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.