I'm fiddling with a custom property editor and I'm using a component that monitors a <textarea> (or similar) for changes, and then updates a hidden <input> field (guess it's similar to what a Markdown editor or an RTE does?).
So I'm assuming the <input> is the ng-model here; only - it's not persisted...
@Tim: It's already TEXT, actually. StackOverflow topic makes sense - will try the curly-brackets (though I seem to remember having tried that, but probably not correctly).
Hmm doesn't even work with the standard textfield...
It's not saving the property (can see that using XMLDump) - so for what it's worth, the binding on initialisation could actually be working - it's just getting an empty property :-)
If I change the textfield manually and hit Save and Publish, it saves correctly.
If the value is set from script, it doesn't Save, i.e. Angular doesn't see the changes
So looks like I'll need to checkout using the $watch() as Bjarne suggests...
Will try the hidden input with ng-value first, since that should work ... (btw: Very confusing that there are all these subtly different approaches - using ng-model, ng-value or the value with double-braces)
I say should work because I don't see how you'd change the value of a hidden field from other than code...
So from script you are setting the value attribute? Why not set $scope.model.value instead , since that is linked to your control it should do the binding for you...
Property Editor binding using hidden input field?
Hi all,
I'm fiddling with a custom property editor and I'm using a component that monitors a
<textarea>
(or similar) for changes, and then updates a hidden<input>
field (guess it's similar to what a Markdown editor or an RTE does?).So I'm assuming the
<input>
is the ng-model here; only - it's not persisted...Starting out, my view is just this:
Shouldn't this populate the
<input>
'svalue
attribute with any saved value when the editor is instantiated?Or does the ng-model binding not work for hidden input fields?
/Chriztian
Comment author was deleted
What happens when you chance the type to text?
Comment author was deleted
Check the thread here http://stackoverflow.com/questions/18446359/angularjs-does-not-send-hidden-field-value
So the ng-model is not rebinding when the value is actually updated.. can you see the model.value being changed using the console.log???
@Tim: It's already TEXT, actually. StackOverflow topic makes sense - will try the curly-brackets (though I seem to remember having tried that, but probably not correctly).
Thanks, /Chriztian
Comment author was deleted
hmm with type text it should just work with ng-model, any js errors ?
Comment author was deleted
what happens if in your view you just add
So no controller just the input
Oh - misunderstood the initial question about setting type to text - thought you meant the
valueType:
key in the manifest file :-)Will try changing the input to text...
Hi Chriztian
I think you should be able to use ng-value attribute since AngularJS 1.2 http://stackoverflow.com/questions/18446359/angularjs-does-not-send-hidden-field-value
Does this work?
or maybe try this for watching changes: http://blog.sapiensworks.com/post/2013/06/22/Binding-AngularJs-Model-to-Hidden-Fields.aspx/
/Bjarne
Hmm doesn't even work with the standard textfield...
It's not saving the property (can see that using XMLDump) - so for what it's worth, the binding on initialisation could actually be working - it's just getting an empty property :-)
/Chriztian
Comment author was deleted
@CHriztian, did you try the basic text field example (so no controller)
Yes - that saves the value...
So what does that tell you?
/Chriztian
Comment author was deleted
That there is probably an issue with your controller
OK, so I've got it down to this:
So looks like I'll need to checkout using the
$watch()
as Bjarne suggests...Will try the hidden input with
ng-value
first, since that should work ... (btw: Very confusing that there are all these subtly different approaches - usingng-model
,ng-value
or thevalue
with double-braces)I say should work because I don't see how you'd change the value of a hidden field from other than code...
Comment author was deleted
So from script you are setting the value attribute? Why not set $scope.model.value instead , since that is linked to your control it should do the binding for you...
Because that's the component doing it for me :)
Comment author was deleted
If you share the complete example I can give some pointers since I think you aren't taking full advantage of the angularjs power ;)
is working on a reply...