Reputation: 2913
I have a foreach loop using php inside that loop im passing three parameters. the problem is when i do a console log the variable being passed the consoles says there undefined, but in the html i can see the html output with the variable being there.
this is my 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>
when i press the ng-click i want to get those 3 arguments being passed. it the html view source i can see the values of all three.
$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');
};
}
})
};
the console.log(firstName) says that the value is undefined. now what an I doing wrong why cannot get those values?
Upvotes: 1
Views: 891
Reputation: 1219
You should add "
.
Try like this:
<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>
Upvotes: 1