angularjs - Best way to get values using ngFormController -
this can't correct, perhaps google has gone off rails life of me can't find documentation return $valid = true values using formcontroller. functionality exist? i'm trying marshall information form , send web service wan't make sensible before doing so. i'm looping through properties in formcontroller given form , looking see if doesn't start $, , $valid = true , pushing array so:
angular.foreach(form,function(data,key) { if(key.indexof('$') === -1 && data.$valid) { var item[key] = data.$modelvalue; clean.push(item); } })
real basic, i'm totally stumped (and can't believe) doesn't exist in angular api somewhere. missing something? i'm still learning lot angular , getting feeling isn't documented perhaps i'm missing quite basic. reading!
this not ngformcontroller
used (for validation , custom directive scripting). if need collection form data send server need make use of ngmodel directives:
<form novalidate ng-submit="saveuser()"> <input type="text" ng-model="user.name"> <input type="text" ng-model="user.email"> </form>
and in controller saveuser
handler can access form data like
$scope.saveuser = function() { console.log($scope.user); // {name: "thomas", email: "mann@ga.com"} // use $scope.user data send server };
Comments
Post a Comment