Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Hidden fields in AngularJs

How do I access hidden fields in angular? I have an app, where I want to submit a form for each of items in the list. The form is simple - it has submit button and a hidden field holding the ID value. But it does not work. The value is empty.

I updated the default angular example to display the situation - the todo text is in hidden field.

http://jsfiddle.net/tomasfejfar/yFrze/

like image 407
Tomáš Fejfar Avatar asked Jun 24 '12 10:06

Tomáš Fejfar


People also ask

What are hidden fields?

A hidden field lets web developers include data that cannot be seen or modified by users when a form is submitted. A hidden field often stores what database record that needs to be updated when the form is submitted.

What is $$ in AngularJs?

The $ in AngularJs is a built-in object.It contains application data and methods.

How do you get hidden field values in typescript?

var h = document. getElementById('myHiddenField');


1 Answers

If you don't want to hardcode anything in your javascript file, you can either load it via AJAX, or do:

<input type="hidden" name="value" ng-init="model.value=1" value="1">

this way, you can keep the form functionality with JS off, and still use the hidden field in AngularJS

like image 178
pocesar Avatar answered Sep 30 '22 13:09

pocesar