Angularjs TypeError:无法获取属性';插入前';仅在IE上存在未定义或空引用
I AngularJS v1.2.0。我只在IE11上遇到以下错误 TypeError:无法在匿名函数(/Scripts/angular.js:3850:11)的forEach(/Scripts/angular.js:303:9)的enter(/Scripts/angular.js:3849:9)的publicLinkFn(/Scripts/angular.js:5420:29)的匿名函数(/Scripts/angular.js:18725:17)的ngRepeatAction)中获取未定义或空引用的属性“insertBefore”(/Scripts/angular.js:18723:15)在$watchCollectionAction(/Scripts/angular.js:11299:11)在Scope.prototype。$digest(/Scripts/angular.js:11395:21)在Scope.prototype。$apply(/Scripts/angular.js:11634:13)在done(/Scripts/angular.js:7635:34) 它在Firefox上运行良好,在执行以下自定义指令时失败Angularjs TypeError:无法获取属性';插入前';仅在IE上存在未定义或空引用,angularjs,internet-explorer-11,typeerror,Angularjs,Internet Explorer 11,Typeerror,I AngularJS v1.2.0。我只在IE11上遇到以下错误 TypeError:无法在匿名函数(/Scripts/angular.js:3850:11)的forEach(/Scripts/angular.js:303:9)的enter(/Scripts/angular.js:3849:9)的publicLinkFn(/Scripts/angular.js:5420:29)的匿名函数(/Scripts/angular.js:18725:17)的ngRepeatAction)中获取未定义或空
.directive('appMyCourseCards', ['$compile', '$log', function ($compile, $log) {
return {
restrict: 'E',
replace: true,
scope: {
},
link: function (scope, element, attributes, controller) {
var content = '<div class="well well-sm bottomSmallMargin" ng-repeat="schedule in studentSubjectSchedules | filterCourses:\'' + attributes.termperiodparingids + '\' ">' +
'<div class="row">' +
'<div class="col-md-12">' +
'<div class="pull-left">{{schedule.SSECName}}</div>' +
'</div>' +
'</div>' +
'</div>';
element.append($compile(content)(scope.$parent));
}
};
.directive('appMyCourseCards',['$compile','$log',function($compile,$log){
返回{
限制:'E',
替换:正确,
范围:{
},
链接:函数(范围、元素、属性、控制器){
变量内容=“”+
'' +
'' +
“{schedule.SSECName}”+
'' +
'' +
'';
追加($compile(content)(scope.$parent));
}
};
任何帮助都将不胜感激
谢谢。能否添加自定义筛选器“filterCourses”的详细信息 我用你的大部分代码创建了这个,它在IE11中运行正常,所以我怀疑可能是过滤器导致了这个问题。 这就是我在普朗克的东西
.directive('appMyCourseCards', ['$compile', '$log', function ($compile, $log) {
return {
restrict: 'E',
replace: true,
scope: {
},
link: function (scope, element, attributes, controller) {
scope.$parent.studentSubjectSchedules = [{SSECName: "name1"}, {SSECName: "name2"}];
var content = '<div class="well well-sm bottomSmallMargin" ng-repeat="schedule in studentSubjectSchedules " >' +
'<div class="row">' +
'<div class="col-md-12">' +
'<div class="pull-left">{{schedule.SSECName}}</div>' +
'</div>' +
'</div>' +
'</div>';
element.append($compile(content)(scope.$parent));
}
}}]);
.directive('appMyCourseCards',['$compile','$log',function($compile,$log){
返回{
限制:'E',
替换:正确,
范围:{
},
链接:函数(范围、元素、属性、控制器){
范围.$parent.studentSubjectSchedules=[{SSECName:“name1”},{SSECName:“name2”}];
变量内容=“”+
'' +
'' +
“{schedule.SSECName}”+
'' +
'' +
'';
追加($compile(content)(scope.$parent));
}
}}]);
感谢您的回复。这个问题似乎是在多次回发后出现的。在我的应用程序中,我使用的是角度模型,当用户更改下拉值时,控制器会更新该模型,然后指令会使用该模型。它在第一次加载时工作正常,但在多次回发中会出现这个问题。您解决过这个问题吗?我是runni进入同一个房间。。。