Hi Sander, Thank you for the answer.
Your solution works fine (I've created a plunker <http://plnkr.co/edit/jNuM37W09chF04Egcsdi> and works) But unfortunately, in my project doesn't. I think the problem is with ui-router that I´m using in my app. When I call the function: Array.prototype.slice.call($document[0].forms[formName].elements) .filter(hasModel); *.map(extractModelController);* .filter(onlyValidModels); the *.map(extractModelController)* function returns all elements in the form that have a ng-model (including invalid), but those elements are in a reseted state (with no name, nothing). I don´t know what can be happening. On Mon, Feb 23, 2015 at 5:19 AM, Sander Elias <[email protected]> wrote: > Hi Gustavo, > > Sure there is. Strangly angular does not provide it out of the box. put > the following code in a service or directive whatever you see fit. > > $scope.getData = function(formName) { > var els = > Array.prototype.slice.call($document[0].forms[formName].elements) > .filter(hasModel) > .map(extractModelController) > .filter(onlyValidModels) > > console.log('result', els); > return els; > > function onlyValidModels(ngModel) { > return ngModel.$valid; > } > > function extractModelController(el) { > return angular.element(el).controller('ngModel'); > } > > function hasModel(el) { > return el.hasAttribute('ng-model'); > } > } > > Does that help? > Regards > Sander > > -- > You received this message because you are subscribed to the Google Groups > "AngularJS" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to [email protected]. > To post to this group, send email to [email protected]. > Visit this group at http://groups.google.com/group/angular. > For more options, visit https://groups.google.com/d/optout. > -- You received this message because you are subscribed to the Google Groups "AngularJS" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. Visit this group at http://groups.google.com/group/angular. For more options, visit https://groups.google.com/d/optout.
