php - 未在部分模板中获取数据

标签 php html css database angular

这是 Angular 和 php 代码。控制台中没有错误,仍然没有在部分模板中获取数据。我检查了我的 PHP 连接,虽然数据没有显示在我的部分模板中,但它工作正常。请帮助我解决问题,提前谢谢你。

menu.html(部分模板)

<div ng-controller="MenuController">
<figure class="menu_jumbotron">
<ul class="breadcrumb">
  <li><a href="home">Home</a></li>
  <li>Menu</li>
</ul>
</figure>
<div class="menu">
<h1><i>{{title}}</i></h1>
<div class="menu_button">
<figure>
  <div>
    <span>Breakfast</span>
    <span>100% Organic</span>
  </div>
</figure>
<figure>
  <div>
    <span>Lunch</span>
    <span>100% Organic</span>
  </div>
</figure>
    <figure>
  <div>
    <span>Dinner</span>
    <span>100% Organic</span>
  </div>
</figure>
<figure>
  <div>
    <span>Beverages</span>
    <span>100% Organic</span>
  </div>
</figure>
<figure>
  <div>
    <span>Desserts</span>
    <span>100% Organic</span>
  </div>
</figure>
</div>
<div>
<table style="background-color:white; margin-left:500px">
    <thead>
        <th style="border:1px solid red">Name</th>
        <th style="border:1px solid red">Price</th>
        <th style="border:1px solid red">Meal Type</th>
    </thead>
    <tbody>
        <tr ng-repeat="item in all_items" >
            <td>{{ item.Name }}</td>
            <td>{{ item.Price }}</td>
            <td>{{ item.MealType }}</td>
        </tr>
    </tbody>
</table>
</div>
</div>
</div>

弹出数据.php

<?php
$host = "localhost";
$user = "xxxxxxxx";
$password = "xxxxxxxxxxxx";
$db = "meoan_organics";

$con = new mysqli($host,$user,$password,$db);

if(!$con)
{
die('Unsuccessful Connection');
}

$sql = "SELECT * FROM `meoan_all_food_items`";

$q = $con->query($sql);

$data = array();

if($q->num_rows >0)
{
while($row = $q->fetch_object())
{
$data[] = $row; 
}
} 
else
{
$data[] = null;
}

$con->close();
echo json_encode($data);
?>

脚本.js

/// <reference path="route.js" />

app.controller("MenuController",['$scope', '$http', '$log', function ($scope,$http,$log) {
        $scope.title = "Our Menu";

        $http.get('database/popdata.php')
        .then(function(data){
        $scope.all_items = data;
        }),function(err){
        $log.error(err);
        }
}]);

最佳答案

试试这个:

        <td>{{ item.name }}</td>
        <td>{{ item.price }}</td>
        <td>{{ item.mealType }}</td>

代替:

        <td>{{ item.Name }}</td>
        <td>{{ item.Price }}</td>
        <td>{{ item.MealType }}</td>

关于php - 未在部分模板中获取数据,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47573090/

相关文章:

javascript - 获取选择框以在不同的选择框中显示所选值

PHP 数组值到 css 样式

javascript - 如何自动改变网站方向LTR\RTL?

php - 使用 phpMyAdmin 导出数据库时出现警告

php - Laravel - 带有未签名主键的表迁移错误

javascript - Jquery 单选按钮焦点不起作用

javascript - 在 javascript/jQuery 中创建数千个 div 的问题

html - 是否可以在 CSS 中制作此图像?

css - 使用标志图像选择 - 边框 CSS 修复

php - 仅从 CSS 中提取路径并排除路径后的任何内容