Take the 2-minute tour ×

How do I implement a field (input for validation purposes only) that would be able to contain a value that does not have to be a string or a number (like object or resource).

I want the input field to behave similar to the select directive, where a value can be any valid JS type (object,array,string etc).

I want to use this field for validation purposes only (it will be hidden).

<input type="hidden" ng-model="fruit" name="fruit citrus-required>
<span ng-show="form.fruit.$invalid">Pick a valid citrus</span> 

<a ng-click="fruit={name:'banana'}">banana</a>
<a ng-click="fruit={name:'orange'}">orange</a>
share|improve this question
add comment

1 Answer

up vote 0 down vote accepted

It turns out that angular has this already covered, http://beta.plnkr.co/edit/Udq8BR6yZhYBCkyR8KDP Just don't know if that is safe ?

share|improve this answer
add comment

Your Answer


