Javascript 如何使用ng click传递php变量
我有一个使用php的foreach循环,在这个循环中我传递了三个参数。问题是,当我做一个控制台日志时,被传递的变量被控制台称为未定义,但在html中,我可以看到变量存在时的html输出 这是我的htmlJavascript 如何使用ng click传递php变量,javascript,php,html,angularjs,Javascript,Php,Html,Angularjs,我有一个使用php的foreach循环,在这个循环中我传递了三个参数。问题是,当我做一个控制台日志时,被传递的变量被控制台称为未定义,但在html中,我可以看到变量存在时的html输出 这是我的html <tbody><?php foreach($rows as $row):?> <tr class="odd gradeA"> <td><a href="#"><?=$row->fi
<tbody><?php
foreach($rows as $row):?>
<tr class="odd gradeA">
<td><a href="#"><?=$row->firstName?> <?=$row->lastName?></a></td>
<td><?=$row->address . ' ' . $row->city . ' ' . $row->state . ' ' . $row->zipCode?></td>
<td><?=$row->email?></td>
<td><?=$row->cellPhone?></td>
<td class="text-right tableIcons">
<a title="Edit User" href="users/edit/<?=$row->userId?>" class="btn btn-primary btn-xs"><i class="fa fa-pencil"></i></a>
<button ng-click="remove(<?=$row->firstName?>, <?=$row->lastName?>, <?=$row->userId?>)" title="Remove User" href="#" class="userRemove btn btn-danger btn-xs"><i class="fa fa-trash"></i></button>
</td>
</tr><?php
endforeach?>
</tbody>
log(firstName)表示该值未定义。现在我做错了什么?为什么不能得到这些值?您应该添加“
试着这样做:
<button ng-click="remove('<?=$row->firstName?>', '<?=$row->lastName?>', '<?=$row->userId?>')" title="Remove User" href="#" class="userRemove btn btn-danger btn-xs"><i class="fa fa-trash"></i></button>
@user3862830如果答案有用,你可以投票,如果答案解决了你的问题,你可以接受。有关更多信息,请阅读以下内容:
<button ng-click="remove('<?=$row->firstName?>', '<?=$row->lastName?>', '<?=$row->userId?>')" title="Remove User" href="#" class="userRemove btn btn-danger btn-xs"><i class="fa fa-trash"></i></button>