Dismiss
Announcing Stack Overflow Documentation

We started with Q&A. Technical documentation is next, and we need your help.

Whether you're a beginner or an experienced developer, you can contribute.

Sign up and start helping → Learn more about Documentation →

I have a form that lives inside an ng-repeat. I'm not using ng-model on the form because I don't think there is a need just yet (it's not an AJAX form). I want to set the default value of one of my text input fields to the value of j.some_attribute, where j is the current iteration of ng-repeat. I've tried value="{{j.some_attribute}}" and ng-value="j.some_attribute", but neither one works. When the form is submitted, the value for that field is blank. Is there a way to set the default value of a text input without creating a form model on the scope?

share|improve this question
    
are you getting any console error ? – Vineet Aug 4 '15 at 20:14
    
Not getting any errors. If I view the page source, I see something like <input value> or <input ng-value> or <input value="j.some_attribute>, depending on if I use value or ng-value and if I enclose the variable in handlebars – ACIDSTEALTH Aug 4 '15 at 20:18
    
ajax is irrelevant...can use ng-model anyway. It will bind to the value property of the element. That being said if ng-value not working it sounds like you have a scope issue. Is element inside a directive? Is it a hidden element? Create demo that replicates the problem – charlietfl Aug 4 '15 at 20:22
    
did you forget to put a name on element? no name means no submit – charlietfl Aug 4 '15 at 20:27
    
It wasn't an issue with name not being specified for the inputs, not was it a scope issue. The form was not inside a directive. I couldn't solve the problem the way I'd hoped, so I refactored the form to use ng-model. – ACIDSTEALTH Aug 5 '15 at 17:34

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.