AngularJS。动态添加的输入不会影响$ valid

时间:2018-12-27 09:25:28

标签: angularjs

试图制作动态组成的表格。

字段和属性来自服务器。 Angular应该获取它们并生成一个表单。

我决定使用指令和运行时编译。

除了一些东西外,几乎所有作品都可以。

问题:已编译字段未定义$ valid。

适用于静态字段。

请给我一个建议。

> Error: Py4JJavaError: An error occurred while calling
> z:org.apache.spark.api.python.PythonRDD.collectAndServe. :
> org.apache.spark.SparkException: Job aborted due to stage failure:
> Task 0 in stage 10.0 failed 1 times, most recent failure: Lost task
> 0.0 in stage 10.0 (TID 30, localhost, executor driver): org.apache.spark.SparkException: Python worker failed to connect back.
app = angular.module('dyno', []);

    app.controller("fieldCompilation", function($scope) {

      $scope.list = [{
          id: "0",
          name: "A"
        },
        {
          id: "1",
          name: "B"
        },
        {
          id: "2",
          name: "C"
        },
      ];


    });
    app.directive("otcDynamic", function($compile) {
      return {
        link: function(scope, element) {
          // Add Text Input with pattern validation and required attr
          var template = "<input type='text' name='input3' ng-model='input3' placeholder='input3 [0-9]{2} required' pattern='[0-9]{2}' required='true'/>";
          var linkFn = $compile(template);
          var content = linkFn(scope);
          angular.element(document.getElementById("f3")).append(content);

        }
      }
    });

Fiddle

0 个答案:

没有答案