Reputation: 1430
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?
Upvotes: 1
Views: 3431
Reputation: 24894
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>
Upvotes: 2
Reputation: 1386
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}}" />
Upvotes: 2