gpt4 book ai didi

AngularJS 类型错误 : Cannot read property 'insertBefore' of null

转载 作者:行者123 更新时间:2023-12-02 23:09:01 24 4
gpt4 key购买 nike

我似乎无法全神贯注于我在这里做错了什么。我正在尝试从 php 文件中提取 json 数据,然后将其显示在我的 Angular 应用程序中。

我的app.js:

var app = angular.module("MyApp", []);

app.controller("ClientHealthCtrl", function($scope, $http) {
$http.get('json.php').
success(function(data, status, headers, config) {
$scope.rows = data;
}).
error(function(data, status, headers, config) {
// log error
});
});

我的 HTML:

<body class="skin-black" ng-app="MyApp">
...
<tbody ng-controller="ClientHealthCtrl">
<tr class="link_back" ng-repeat="Computer in rows">
<td><a href="#cid={{Computer.id}}">{{Computer.ComputerName}}</a></td>
<td><i class="fa fa-fw fa-check-square" style="color:#008000;"></i>{{Computer.WmiTest}}</td>
<td><i class="fa fa-fw fa-check-square" style="color:#008000;"></i>{{Computer.SmsClientService}}</td>
<td><i class="fa fa-fw fa-check-square" style="color:#008000;"></i>{{Computer.McAfeeFrameworkService}}</td>
<td><i class="fa fa-fw fa-check-square" style="color:#008000;"></i>{{Computer.RemoteManagement}}</td>
</tr>
</tbody>

这会导致...

TypeError: Cannot read property 'insertBefore' of null
at https://ajax.googleapis.com/ajax/libs/angularjs/1.0.2/angular.js:2067:13
at forEach (https://ajax.googleapis.com/ajax/libs/angularjs/1.0.2/angular.js:113:18)
at forEach.after (https://ajax.googleapis.com/ajax/libs/angularjs/1.0.2/angular.js:2066:5)
at Object.JQLite.(anonymous function) [as after] (https://ajax.googleapis.com/ajax/libs/angularjs/1.0.2/angular.js:2104:17)
at https://ajax.googleapis.com/ajax/libs/angularjs/1.0.2/angular.js:13294:22
at https://ajax.googleapis.com/ajax/libs/angularjs/1.0.2/angular.js:3745:29
at Object.<anonymous> (https://ajax.googleapis.com/ajax/libs/angularjs/1.0.2/angular.js:13293:13)
at Object.Scope.$digest (https://ajax.googleapis.com/ajax/libs/angularjs/1.0.2/angular.js:7693:38)
at Object.Scope.$apply (https://ajax.googleapis.com/ajax/libs/angularjs/1.0.2/angular.js:7894:24)
at done (https://ajax.googleapis.com/ajax/libs/angularjs/1.0.2/angular.js:8883:20)
enter code here

最佳答案

尝试包装 <tr>...</tr> <div>...</div> 内的元素.

查看Angular的源代码,它提示某些节点没有父节点。

实际上,我在寻找修复代码中的相同错误时发现了您的问题。我就是这么做的,而且成功了。

关于AngularJS 类型错误 : Cannot read property 'insertBefore' of null,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26103174/

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