Form Validation and fields added with $compile

前端 未结 1 1421
梦谈多话
梦谈多话 2020-12-06 17:04

I have a question regarding form validation. It is not working for me in the following scenario:

I have a global form, inside the form dynamic fields are rendered us

1条回答
  •  伪装坚强ぢ
    2020-12-06 17:40

    I found solution for this issue, in this Q & A: AngularJS: Error: No controller: form. The trick is:

    1. firstly do append element
    2. next do compile

    Here is the changed code snippet:

    directive = '
    '+directive+'
    '; // Do Not compile the element NOT beeing part of the DOM //$(element).append($compile(directive)(scope)); // Firstly include in the DOM, then compile var result = $(directive).appendTo(element); $compile(result)(scope);

    Here is working jsfiddle

    0 讨论(0)
提交回复
热议问题