javascript - Cannot pass token to a form in AngularJS -
i'm new angular , i'm doing wrong. i'm using 2 angularjs applications don't want have log in logic in main application.
i'm trying submit regular html form doing:
document.getelementbyid("loginform").submit();
this form:
<form method="post" id="loginform" action="main.html"> <input type="hidden" name="token" value="{{regdata.token}}"/> </form>
the problem on server "i'm not getting last regdata.token value.
here js code:
$scope.login = function () { $scope.regdata.token = "very old data"; $http .post('/authenticate', $scope.user) .success(function (data, status, headers, config) { $scope.regdata.token = "very new data"; document.getelementbyid("loginform").submit(); }) .error(function (data, status, headers, config) { delete $window.sessionstorage.token; delete $window.sessionstorage.username; alert(data); }); };
on server i'm getting "very old data". assumption in success callback new $scope created, trying emit changes up, no luck.
any idea how new value "very new data"?
any response highly appreciated.
in angular use ng-model instead of val. see aren't sending object in question. instead sending $scope.user have not defined. suggest reading more on angularjs forms before continuing -http://scotch.io/tutorials/javascript/angularjs-form-validation
Comments
Post a Comment