EmberJS Handle Bars Inputs - javascript

I have the following:
<span>{{m.search_type}}</span>
{{input value=m.search_type}}
I retrieve the search_type with
this.get(search_type) in the controller that handles the form submission.
However, when I change the input value, the value within the <span>..</span> will change. This is the defined behavior in the docs.
I want the span to be the title for the input field and to not change along with the value of search_type. Search type is dynamic so I can't just hardcode the value for {{m.search_type}}.
Is there a way to do this? I tried creating a EmberJS Helper to map the value to a new string but this still changes whenever search_type changes.

Properties are always bound by default. Use the unbound helper to unbind the property.
<span>{{unbound m.search_type}}</span>
{{input value=m.search_type}}

Related

Which event is triggered when v model value is changing

I'm new to Vuejs and my requirement is to write a single functional globally to trigger whenever v-model value of my form elements are set. I tried to write this for element.onchnage but this is not working.
Can some one tell me which HTML event is triggered when the v-model value is set in vuejs ?
Hey Linu and welcome to SO.
Check out the docs for Form input bindings:
https://v2.vuejs.org/v2/guide/forms.html
There it says:
v-model internally uses different properties and emits different
events for different input elements:
text and textarea elements use value property and input event
checkboxes and radiobuttons use checked property and change event;
select fields use value as a prop and change as an event.
So instead of v-model you can do the following for inputs
<input :value="dataProperty" #input="dataProperty = $event.target.value" />

How to get both check box values and radio button values in angular.js

My demo https://embed.plnkr.co/R4mdZr/
I am new to angular as I mentioned I want to get both checkbox true values and radio button values ..
There is a condition if ingredients minimum value is equal to one means it will show as radio or else checkbox .
How to get those values?
You should use ng-model when you're dealing with inputs. I'm not sure what values you want in your model, but you would typically use the ng-value directive here to assign a certain property, or perhaps the whole object to your ng-model.
For example
ng-value="get_ing_n"
Would assign the complete object to your model when you select a radio.
ng-value="get_ing_n.ingredientName"
Would bind the ingredientname.
I forked your plunker to demonstrate this. Beware however that there are some ng-init's present to format the model. It is generally not considered a good practice to put this logic into the view, so it's best to just use this as a reference.
If you want to apply some additional logic when selecting a checkbox/radio button, you can use the ng-change directive where you can call a function on your controller on model changes.

Apply changes with binding

I am searching on how to firechange to an input field after applying changes using code. Here is the code:
Otable.getModel().setProperty("/Products(1)/Price",29)
How can i fire the change to the input field?
If you have specified the correct binding mode from model to view (one-way or two-way should work in this case) and bound the value of your input field to the property in the model, it should update automatically and you shouldn't have to fire any change to the input field manually.
If you implemented the data binding correctly, a change in the model should reflect to the input field and vice versa.
var oInput = new sap.m.Input({
value: "{/value}" // path to the property here
});
Take a look at this fiddle: https://jsfiddle.net/nkLtqa5p/
and also at this tutorial regarding data binding here: https://sapui5.hana.ondemand.com/#docs/guide/e5310932a71f42daa41f3a6143efca9c.html

Angular send only changed fields of model or Replicate model with change

I prepared the form through angular.But when I need to submit the form so how can I send only all changed field or selected option values.
Need Some thing which works in all Scenario of input form fields.
DEMO: demo for ref.
on click of save how can i get it something like below one
{"list":[{"selectedOption":{"id":[]}}],"active":true,"chk_list":[{"selectedOption":{"id":["2","3"]}}],"name":"ssss"}
If you want the object to be returned to have only specific fields, then the result object should be different from the "myData" object, that you are using to actually display all the possible options to the user, etc.
Try this : http://jsfiddle.net/tc7dhep3/
I have created another variable
$scope.result
that contains the info to be sent on save button click.
The $dirty property for input elements tell if the user interacted with this, you can use this property to say which field was modified.
frm.name.$dirty
Angular doc: input - directive in module ng
You can combine this with ng-change or ng-submit to build the post object
Exemple: DEMO Forked from yours

AngularJS - Bind input to value with filter and update it

I have an input bound to an object property and with a filter applied to it.
<input value="{{object.field | filter}}">
The problem is that if I programmatically change object.field, the value displayed inside the input doesn't change, however in the DOM Inspector I see the correct (new) value. I verified to digest/apply the changes to the scope and the object.field variable does change correctly, the issue seems to be only in the input displayed value.
I cannot provide an example since there's too much code involved.
Does anyone know where I should look for errors??
No need to set value in that way. ng-model takes care of it.
Valid syntax is:
<input ng-model="object.field">
For filtering you can look at this answer:
Using angularjs filter in input element
I think you should use ng-model to bind your data into input box instead {{expression}}

Categories