Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/html/84.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 使用Firebase和Angular填充数据表_Javascript_Html_Angularjs_Firebase_Angularfire - Fatal编程技术网

Javascript 使用Firebase和Angular填充数据表

Javascript 使用Firebase和Angular填充数据表,javascript,html,angularjs,firebase,angularfire,Javascript,Html,Angularjs,Firebase,Angularfire,我对Firebase和整个web开发spiel非常陌生 我试图用Firebase中的数据填充网站中的数据表 下面是app.js var app = angular.module("aocgApp", ["firebase"]); app.controller("dataController", ["$scope", "$firebaseArray", function($scope, $firebaseArray) { var national = new Firebase("htt

我对Firebase和整个web开发spiel非常陌生

我试图用Firebase中的数据填充网站中的数据表

下面是app.js

var app = angular.module("aocgApp", ["firebase"]);
app.controller("dataController", ["$scope", "$firebaseArray", 
function($scope, $firebaseArray) {
    var national = new Firebase("https://aoconsultinggroup.firebaseio.com/National");
    $scope.schools = $firebaseArray(national);
}]);
最后,html代码:

<div class="panel-body">
<div ng-app="aocgApp" ng-controller="dataController">
<div class="table-responsive">
    <table class="table">
        <thead>
            <tr>
                <th>School Name</th>
                <th>SATs</th>
                <th>GPA</th>
                <th>Tuition</th>
            </tr>
        </thead>
        <tbody>
            <tr ng-repeat="school in schools">
                <td>{{ schools.name }}</td>
                <td>{{ schools.sat24l }}</td>
                <td>{{ schools.gpa }}</td>
                <td>{{ schools.tuition }}</td>
            </tr>
        </tbody>
    </table>
</div>
</div>
</div>

模板中的变量名称错误,它是
学校
而不是
国家

<tr ng-repeat="school in schools">
  <td>{{ school.name }}</td>
  <td>{{ school.sat24l }}</td>
  <td>{{ school.gpa }}</td>
  <td>{{ school.tuition }}</td>
</tr>

这就是
school-in-schools
在模板中起作用的原因。
schools
变量来自控制器的
$scope
,而
school
变量是在模板中创建的。

哎呀,我在html中玩弄变量名。但是非常感谢你!我现在就试试这个,然后回到线程上来!我错过什么了吗?因为它仍然不起作用。我从Firebase教程中复制并粘贴了一个函数,用于检查与Firebase建立的连接。而且它在连接上没有任何问题。我太迷路了…你能清楚什么不起作用吗?另外,如果您可以发布数据库的结构,这将很有帮助。因此,根本不会填充datatable。我将编辑关于从您的数据结构更新的数据结构的原始帖子。这里至少有两个明显的打字错误。请在要求他人调试您的代码之前进行尽职调查
schools
$loaded
回调(您不需要)中,应该是$scope.schools,
ng repeat
应该指
school in schools
。在您发表评论之前很久就已经处理过了。很抱歉,我忘了在原来的帖子中修复它。即使在加藤之后,数据表也没有被填充,还有什么问题呢?我已经为此挣扎了两天,没有成功或线索
<tr ng-repeat="school in schools">
  <td>{{ school.name }}</td>
  <td>{{ school.sat24l }}</td>
  <td>{{ school.gpa }}</td>
  <td>{{ school.tuition }}</td>
</tr>
var national = new Firebase("<your-firebase-app>/National");
$scope.schools = $firebaseArray(national);