Pass php variable/array data to angular js

I am using php database connectivity with “$row” as an array that stores name as a field in it .But after lots of searching i dint get how to pass php variable in angular js
here’s the code ,I am trying to is it possible i am new to this your help will be appreciated.


$con = mysqli_connect('localhost','root','','practice');

die("couldnt connect".mysqli_error);
$q= "select * from test";
$result= $con->query($q);


while($row = $result->fetch_assoc()){

echo $row['name']."<br>";
echo json_encode($result);


<ul ng-init="names = <?php echo htmlspecialchars(json_encode($row)); ?>">
<li ng-repeat="x in names">

Source: json

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.