Getting form controls from FormController

前端 未结 4 1649
清歌不尽
清歌不尽 2020-12-30 22:48

I need a way to loop through the registered controls of an AngularJS form. Essentially, I\'m trying to get all the $dirty controls, but there\'s no array of the controls (t

4条回答
  •  盖世英雄少女心
    2020-12-30 23:14

    You can use the following code to iterate the controls:

        var data = {};
        angular.forEach(myForm, function (value, key) {
            if (value.hasOwnProperty('$modelValue'))
                data[key] = value.$modelValue;
        });
    

提交回复
热议问题