无法读取属性'insertBefore'在forEach.after处为null
Cannot read property 'insertBefore' of null at forEach.after
我有一个非常简单的html页面,在那里我使用ng-include
:-加载两个不同的html文件
<body ng-controller="testCtrl">
<div class="panel panel-primary">
<h3 class="panel-heading">Test</h3>
<ng-include src="'View/Details.html'" ng-show="details" />
<ng-include src="'View/Summary.html'" ng-show="summary" />
</div>
</body>
最初只有details
变量为真,因此它正在加载Details
视图,该视图如下所示:-
<div class="panel-body">
<table class="table table-striped table-bordered">
<thead>
<tr>
<th>Id</th>
<th>Name</th>
</tr>
</thead>
<tbody>
<tr ng-repeat="item in items">
<td>{{item.id}}</td>
<td>{{item.name}}</td>
</tr>
</tbody>
</table>
</div>
这是控制器供参考:-
.controller("testCtrl", function ($scope) {
$scope.loadItems = function () {
$scope.items= [
{ id: 1, name: "dummy" },
{ id: 2, name: "dummy1" },
{ id: 3, name: "dummy2" }
];
}
$scope.loadItems();
}
当我加载页面时,它正确显示数据,但没有触发任何事件(所有按钮点击处理程序都通过ng-click
&与控制器中定义的行为关联),所以我继续检查控制台,它显示以下错误:-
TypeError:无法读取null的属性"insertBefore"位于forEach.after(myUrl)在Object.JQLite.(匿名函数)[在之后]
我对Angular很陌生。我看到了一些线程,并试图操纵我的标记代码,但没有成功。
您不能<ng-include/>
--应该是<ng-include></ng-include>
。同样,ng-if通常比ng-show更好,因为它减少了结果html的数量。
休息工作:plnkr.co/edit/EmUYuHltWaXnjEC6juid?p=预览。
相关文章:
- Foreach无法在Typescript中工作
- $rootScope未使用forEach进行更新
- 如何制作简单的php'在Javascript中的foreach等价物
- missing ) after argument list DATEDIF
- 用独立变量敲除foreach绑定
- Knockout.JS标签在foreach内部不起作用
- 在foreach中获取ajax结果
- 如何在foreach循环中对每个产品单独应用评级系统
- 如果数组仍在执行,async.forEach()将运行我添加到数组中的新元素
- 错误:Can't在从forEach循环发送标头后设置标头
- 为什么我们在ES2015中需要一个新的for循环结构,而我们已经有了for、forEach
- 在foreach中加载所有项后,Knockoutjs组件回调
- Javascript:foreach跳过第一个索引(0)
- 嵌套foreach逐字母读取值,而不是整个单词
- Foreach无法在php和Jquery中工作
- 如何在PHP foreach中使用ajax
- SlideDown()不会'不能在jQuery中使用After()
- 在输入forEach(javascript)时重置变量
- Foreach循环只返回最后一个值
- 无法读取属性'insertBefore'在forEach.after处为null