【发布时间】:2016-03-28 09:02:30
【问题描述】:
如何在 ejs 中将对象作为参数发送。当我尝试在测试函数的参数中发送对象时,它会打印 undefined 。
</tr>
<% userlist.forEach(function(usr){ %>
<tr>
<td><input readonly type="text" value="<%= usr.name %>"></td>
<td><input readonly type="text" value="<%= usr.email %>"></td>
<td style="cursor:pointer">
<i title="edit data" style="padding-right:18px" class="fa fa-pencil"></i>
<i title="delete" ng-click='test(<%= usr %>)' class="fa fa-trash"></i></td>
</tr>
<% }) %>
<% } %>
【问题讨论】:
-
不清楚你在问什么,发给谁和什么对象?
-
将对象作为参数发送到角度测试函数。这里:ng-click='test()'
-
看起来你正在做的应该可以正常工作。用户的姓名和电子邮件地址是否显示在表格中?你能展示你的 AngularJS
test函数吗? -
alert 带有 undefined : app.controller('cntr',function($scope , $http){ $scope.test=function(obj){ alert(obj);} });
标签: angularjs node.js mongodb mean ejs