【问题标题】:Angular dynamic form is not working in IE角度动态表单在 IE 中不起作用
【发布时间】:2017-08-09 15:23:54
【问题描述】:

我在我们的应用程序中使用 Angular 1.6。我们有一个在 Internet Explorer 11 (IE-11) 中不起作用的动态表单指令。 Html 表单组件在屏幕中加载时会阻塞屏幕,因为这些组件不是动态创建的。如何使其工作?

【问题讨论】:

  • 请分享您的代码。
  • 当询问由您的代码引起的问题时,如果您提供人们可以用来重现问题的代码,您将获得更好的答案。见How to create a Minimal, Complete, and Verifiable example。
  • 描述问题。“它不起作用”不是问题陈述。告诉我们预期的行为应该是什么。告诉我们错误消息的确切措辞是什么,以及产生它的代码行。在问题的标题中简要说明问题。
  • 1.详细解释预期的结果应该是什么; 2.分享你的代码; 3.简要说明您面临的问题; 4. 与代码相关联,以便清楚了解从哪里开始调查; 5. 解释你试图解决问题的方法

标签: angularjs angularjs-directive


【解决方案1】:

动态表单无法在 IE11 上正常工作。可以明确地使其与 IE 一起工作。

通过控制器 js 创建显式 html 组件。

    document.createElement('ng-include');
    document.createElement('ng-pluralize');
    document.createElement('ng-view');
    document.createElement('ng-form');
    document.createElement('dynamic-form');

    // Optionally these for CSS
    document.createElement('ng:include');
    document.createElement('ng:pluralize');
    document.createElement('ng:view');
    document.createElement('ng:form');

    // IE doesn't always run the bootstrap on its own...
    angular.element(document).ready(function () {
      angular.bootstrap(document.documentElement);
    });

明确地,您需要在 dynamic-form.js 文件中进行一些修改。当元素未定义或为 null 时,通过添加 null/undefined 检查来绕过该元素

 while (!angular.equals(iterElem.parent(), $document) && !angular.element(iterElem.parent()[0])== undefined || !angular.element(iterElem.parent()[0])== null) {
//logic will come here for iteration
}

【讨论】:

    猜你喜欢
    • 2017-11-20
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-06-29
    • 1970-01-01
    • 2019-05-13
    • 1970-01-01
    相关资源
    最近更新 更多