Rectangle 27 0

javascript Bind hidden inputs to model in angular?


<input type="hidden" ng-model="record.usersId" value="{{user.userId}}" ng-init="record.usersId=user.userId"/>

You can use something like this:

Note
Rectangle 27 0

javascript Bind hidden inputs to model in angular?


<button ng-disabled="!frmInput.$valid" ng-click="saveRecord()">Accept</button>
function SaveRecord(){
  $scope.record.usersId = $scope.user.userId;
  $scope.record.userNameId = $scope.user.userNameId;
  http.post(url, $scope.record);
}

As a side note, you no need to mention your variable while calling the function

Having hidden variables is not angular way you don't need hidden variables at all, as the all the scope variables (which are not in form) can be taken as hidden variables As for solution,

Yes, finally i did that, with similar approach

while submitting the form, just populate the object 'record' with 'user'

Note
Rectangle 27 0

javascript Bind hidden inputs to model in angular?


<input type="hidden" name="userId" value="{{user.userId}}"/> {{user.userId}}
<input type="hidden" name="UserNameId" value="{{user.userNameId}}"/> {{user.userNameId}}
SaveRecord(record)
record
userNameId
usersId

Hidden field does not support double binding.

does not work. why name attribute?

Note