1

I'm attempting to pass form information through hidden input like so:

<input type="hidden" required ng-model="formHolder.template[position].itemKey[itr]" ng-value="[[ formItem ]]" />

formItem can be any string. Errors occur with strings that contain spaces.

Error angular.js:13708 Error: [$parse:syntax] Syntax Error: Token 'Line' is an unexpected token at column 9 of the expression [Subject Line] starting at [Line].

Is ng-value expecting a certain type?

Glenn Dayton
  • 1,410
  • 2
  • 20
  • 38

2 Answers2

2

I think this might be what you're looking for: AngularJS does not send hidden field value

Specifically, you can bind the data from angular to the normal HTML value tag as such:

<input type="hidden" name="someData" value="{{data}}" />
Community
  • 1
  • 1
nmg49
  • 1,356
  • 1
  • 11
  • 28
2

First, ng-model doesn't work on hidden inputs, so you can just use ngValue to achieve what you want.

The problem is that you're using the incorrect syntax on ngValue directive.

Here's an example:

angular.module('app', [])
  .controller('mainCtrl', function($scope) {
    
  });
<!DOCTYPE html>
<html ng-app="app">

<head>
  <script src="https://cdnjs.cloudflare.com/ajax/libs/angular.js/1.5.7/angular.min.js"></script>
</head>

<body ng-controller="mainCtrl">
  <input type="text" ng-model="value" placeholder="Type value to hidden input">
  <input type="hidden" ng-value="value">
  <hr>
  Value of input hidden (or check it in console):
  <pre ng-bind="value"></pre>
</body>

</html>
developer033
  • 24,267
  • 8
  • 82
  • 108