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?

2

2 Answers 2

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>

Sign up to request clarification or add additional context in comments.

Comments

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}}" />

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.