您好,我在将参数传递给名为addToHistory(param)的函数时遇到了麻烦。当我尝试写入控制台时,它只是说未定义,但当我尝试传递一个数字时,它会在控制台上正确显示。
$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>
答案 0 :(得分:3)
ng-click="addToHistory(task.info)"
删除函数调用中的括号