angularjs - Angular $scope module value lost on form submit -
angularjs - Angular $scope module value lost on form submit -
i instantiating object used store form values:
$scope.placesomething = { somethingtype: 1 };
and form
<form name="placesomething" id="placesomething" novalidate ng-submit="submitform();"> ...form stuff... </form>
if check existance of default value of$scope.placesomething.somethingtype
within controller, prints 1
- good.
but when i'm submitting form, default value lost (unless i'm applying value somethingtype
in other function)
$scope.submitform = function () { console.log($scope.placesomething.somethingtype); // returns undefined. default values lost });
if utilize ng-init within form, angular keeps default value , sends form.
<input type="hidden" ng-model="placesomething.somethingtype" ng-init="placesomething.somethingtype = 1"/>
why happening?
edit
another funny thing, if alter $scope value other $scope, not lost on submit.
$scope.selectsomethingtype = function (param, somethingtype, param2) { $scope.placesomething.somethingtype = somethingtype; });
this function activated in 1 of forms ng-clicks , saves value somethingtype
fine.
solved
http://stackoverflow.com/a/26905500/3628867 problem
angularjs
Comments
Post a Comment