gpt4 book ai didi

php - 来自 MySQL 数据库的 AngularJS 值

转载 作者:行者123 更新时间:2023-11-29 01:53:36 24 4
gpt4 key购买 nike

我看了几个关于它的教程,但我不知道哪里出了问题:

HTML

<!DOCTYPE html>
<html ng-app="dfuApp" ng-controller="dfuController">
<head>
<title>Angular JS Test</title>
</head>
<body>
<div>
current status: {{status}}
</div>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.3.15/angular.min.js"></script>
<script type=”text/javascript” src="js/app.js"></script>
</body>
</html>

aps.js

//Define an angular module for our app 
console.log('here');
var app = angular.module('dfuApp', [])

app.controller('dfuController', function ($scope, $http) {
getStatus();
function getStatus() {
$http.get("../getStatus.php").success(function (data) {
$scope.status = data; //the data are stored in projects
});
};
});

getStatus.php

<?php

$mysqli = new mysqli(credentials);

// The mysql database connection script

$query = "select statusid from metadata";
$result = $mysqli->query($query) or die($mysqli->error . __LINE__);

$arr = array();
if ($result->num_rows > 0) {
while ($row = $result->fetch_assoc()) {
$arr[] = $row;
}
}

//JSON-encode the response
echo $json_response = json_encode($arr);

此示例取自多个示例站点,如 this , that最后 this here .

我仔细检查了一下,没有发现任何错误。在我的控制台中,它说:

[$injector:modulerr] http://errors.angularjs.org/1.3.15/$injector/modulerr?p0=dfuApp&p1=Error%3A…gleapis.com%2Fajax%2Flibs%2Fangularjs%2F1.3.15%2Fangular.min.js%3A17%3A381)

最终导致以下结果:

This error occurs when a module fails to load due to some exception. The error message above should provide additional context.

知道为什么这不起作用吗?我错过了什么?

最佳答案

应该是"而不是

转换这个

<script type=”text/javascript” src="js/app.js">

对此

<script type="text/javascript" src="js/app.js">

关于php - 来自 MySQL 数据库的 AngularJS 值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34808099/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com