我已经编写了一个基于AngularJS的简单HTML。它具有一组预定义的项目,并且提供了Add
和Delete
按钮用于从列表中添加或删除项目。 Delete
按钮是自定义指令。下面是代码示例:(<delete-button>
是自定义指令)
的HTML
项目
<p>
<label>Price</label> <input type="text" ng-model="price" />
</p>
<p>
<button class="btn btn-success" ng-click="addItems()">Add</button>
</p>
<table class="table table-striped table-hover">
<th>Item Name</th>
<th>Item Price</th>
<th>Action</th>
<tr ng-repeat="item in items|filter:name|orderBy:predicate">
<td>{{item.name}}</td>
<td>{{item.price | currency}}</td>
<td><delete-button>Remove</delete-button></td>
</tr>
</table>
Java脚本
$scope.addItems = function() {
$scope.start();
var newItem = {name: $scope.name , price: $scope.price};
$scope.items.push(newItem);
$scope.complete();
};
myModule.directive("deleteButton", function() {
return {
restrict: "E",
transclude: true,
template: "<button class='btn btn-warning' ng-click='removeItem(item)' ng-transclude></button>"
};
});
该代码在Chrome和Firfox上运行良好,但是当我尝试在IE 8上运行它时,它在控制台中给出了
"Error: Unknown Runtime Error"
。没有其他日志。 最佳答案
似乎IE 8无法处理自定义指令。删除自定义指令后,代码运行良好。 IE documentation指出,对于自定义元素指令,我们需要调用document.createElement('custom-element')
。
关于javascript - 带有AngularJS的IE 8中的未知运行时错误,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/24949847/