AngularJS form reinforcement when adding dynamic elements

I have an AngularJS validated form.
The problem is that I am adding input elements to this form using Jquery, and AngularJS does not add these elements to the validation form.
Here is an example: http://jsfiddle.net/ULEsy/

var input = $compile($('<input type="text" ng-model="textinput" required />'))($scope);
$("#someform").append(input);

In this example, although the input field is invalid (empty - visible with a red frame), the entire form is valid. Any help?

+4
source share
1 answer

@Ephi, . -, DOM, $. , .

angular.module("app", []).controller('someController', function($scope, $compile) {   
    $scope.add = function() {
        var input = $('<input type="text" ng-model="textinput" name="x" required />');
        $("#someform4").append(input);    
        $compile(input)($scope);
    }
});
+2

All Articles