无法通过MySQL在AngularJS项目中显示数据库数据

时间:2016-12-09 20:26:15

标签: php mysql angularjs

我在https://phpcmsforce.wordpress.com/处遵循了代码,但似乎无法显示数据。 请告诉我,如果我遗失了什么!

的index.html:

<!DOCTYPE html>
<link rel="stylesheet" href="bower_components/bootstrap/dist/css/bootstrap.css" />
<link rel="stylesheet" href="app.css" />
<script src="bower_components/angular/angular.js"></script>
<script src="app.js"></script>

<html ng-app=”rjtApp”>

<head>BLAH </head>

<body ng-controller=”projectsController”>
<div ng-include src=”Project.html”></div>

</body> </html>

Project.html:

<!DOCTYPE html>
<html lang="en">
<head></head>
<meta charset="UTF-8">

<body>
<table ng-controller=”projectsController”>

    <thead><tr><th>Title</th><th>App Type</th><th>Code</th><th>Type</th></tr></thead>
    <tbody>

    <tr ng-repeat="project in projects">
        <td>{{project.title}}</td>
        <td>{{project.type}}</td>
        <td>{{project.pcode}}</td>
        <td> <div ng-if="project.proj_type = 'Internal'"> <span class='label label-primary'>{{project.proj_type}}</span> </div> <div ng-if="project.proj_type = 'External'"> <span class='label label-info'>{{project.proj_type}}</span> </div> </td>

    </tr>
    </tbody> </table>

app.js:

'use strict';
var app = angular.module('rjtApp' []);

app.controller('projectsController', function ($scope, $http)
{
 getProject();
 function getProject() {
$http.post("getProject.php").success(function(data)) {
  $scope.projects = data;
  });
 };
}

的config.php:

<?php

define('DB_USERNAME', 'root');
define('DB_PASSWORD', '');
define('DB_HOST', '127.0.0.1');
define('DB_NAME', 'project');
?>

getProject.php:

<?php
require_once'config.php';

$query="select * from tbl_projects";
$result = $mysqli->query($query) or die($mysqli->error,__LINE__);
$arr=array(); if($result->num_rows>0) {
    while ($row = $result->fetch_assoc()) {
        $arr[] = $row;
    }
}
echo $json_response = json_encode($arr);
?>

它只是在Project.html浏览器上显示{{project.title}}等。 当我显示index.html时,没有任何显示 我无法弄清楚我做错了什么

0 个答案:

没有答案