1

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?

1 Answer 1

1

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>
Sign up to request clarification or add additional context in comments.

1 Comment

@user3862830 If the answer is useful you can up vote, and if the answer solve your problem you can accept it. For more info read this: stackoverflow.com/help/someone-answers

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.