Angular: Set value of text input without creating a model - angularjs

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?

Related

Update form field value dynamically

I need to update the form field value using javascript as below:
var frmRec = App.frmEdit.getRecord();
frmRec.set('CallingName', 'Tesing calling name');
When I check the form data via the console, I can see the calling name field is updated:
console.log('rec: ', App.frmEdit.getRecord());
But the textfield in the form is not updated, old values still show up in the form. How can I "refresh" the value of the TextField in this case ?
Thanks in advance
If your data binding is setup correctly there is no need to refresh anything. The Extjs form supports two-way binding change to the record would be reflected in the text field and any change to the text field would be updated in the record.
two way binding example
The kitchen sink examples have lots of data binding examples.

How to set values after click in antd rules?

I have the following error.
You cannot set a form field before rendering a field associated with the value.
I was trying to set values on the input after clicking.
Any suggestion?
I guess you are trying to access the form element before rendering, which implies you have written some condition for the form rendering.
So wait until the condition satisfies and then access form fields.

angularjs form ignors non form fields on submit

i am using angularjs' form stuff to gather user information. to get time i user <timpicker> it seems that this field is not set (ng-model of timepicker is null) if i call my ng-submit="submit()".
The only way i found so far is to call ng-change in timepicker and set a viable in scope which is then used in submit. Beside the fact that this is ugly, the main problem is if the user doesn't change the value (default is now) i don't have a time.
Is there a way to gather all ng-model variables in $scope on form's "ng-submit"?
EDIT It is not a problem of form its problem of timepicker. As soon as i change the time once the model gets filled (without the need of change method)
It will gather all ng-model variables on $scope that are set on input fields within the form. If you want to add a variable to your form without actually showing it on the screen, you can do:
<input type="hidden" ng-model="yourVariable" />

is ng-model allowed inside <td> element of a table?

Is ng-model allowed inside element of a table? Will angular automatically update the model if I change a particular column(i.e. view)?
If you are making the table cells directly editable using the HTML contenteditable attribute, ng-model won't work automatically as by default it's only for form elements.
It is possible to make it work with contenteditable though. There is an working example of how to do it on the angular website at http://docs.angularjs.org/api/ng.directive:ngModel.NgModelController
ng-model is allowed wherever typical form elements exist that can use the directive (input, select and textarea)
One thing I will say about ng-model that can make it a bit tricky is that you will want to bind ng-model to a property of an object rather than just a simple scope variable. I have run into several instances where I bind $scope.foo to ng-model and use it in an input control. Then, if you clear the input field, the binding is lost and it stops updating the variable. Use something like $scope.fooObj.modelProp where fooObj is an object and it will work fine.

Salesforce - Populate text are from drop down selection

I have a picklist with three values and a text area that has three values as well, but I would like to correlate one value from the picklist with one value of the text area. Any thoughts as on how I can do this?
If creating a visualforce page is an option, you can do this with a controller extension, or a custom controller. For example, you could override the save() method and have your new save code populate the text for you-- simply create a map of dropdown values to text area content and set the text as desired. It should also be possible to do this without saving by using some of the visualforce built in AJAX hooks: look at the onchange attribute. (Note that last I checked the onchange did not fire properly for lookups, but it may work for dropdowns)
Have a look at the visualforce documentation here: http://www.salesforce.com/us/developer/docs/pages/index.htm

Resources