【发布时间】:2015-08-21 10:08:04
【问题描述】:
我有一个使用 php 的 foreach 循环,在该循环中传递三个参数。问题是当我做一个控制台日志时,传递给控制台的变量说那里未定义,但在 html 中我可以看到 html 输出,变量在那里。
这是我的html
<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>
当我按下 ng-click 时,我想要传递这 3 个参数。它是 html 视图源,我可以看到所有三个的值。
$scope.remove = function(firstName, lastName, userId){
console.log(firstName);
$scope.firstName = firstName;
$scope.lastName = lastName;
var modalInstance = $modal.open({
animation: $scope.animationsEnabled,
templateUrl: 'remove.html',
controller: function($scope, $modalInstance){
$scope.cancel = function () {
$modalInstance.dismiss('cancel');
};
}
})
};
console.log(firstName) 表示该值未定义。现在我做错了什么,为什么不能得到这些值?
【问题讨论】:
标签: javascript php html angularjs