how to detect input value change without entering key value - html

For instance:
<input class="table-input" type="number" name="qty" [(ngModel)]="cpy.qty"
matInput min="1" max="{{cpy.qty}}"
where cpy is object.
And cpy.qty is changing dynamically. Now I have to perform operation on onInputChange
How to detect dynamically inputchange Value?

For dynamically changed value, you can handle change logic with ngDoCheck https://angular.io/api/core/DoCheck

Related

Angular: how to call input ngModelChange when value set for first time from httpResponse

I am having few input elements whose default value is coming from HttpResponse and on their value change i am calling ngModelChange and performing other operations on it..but how would I get the value set on first time.
I tried adding ngAfterContentChecked but it will get called every time which will affect performance.
Is there any way to get an event to get first-time set value.
Current input box is
<input placeholder="email" (ngModelChange)="onEmailChange($event)"
[disabled]="disableEmail" [ngModelOptions]="{standalone: true}"
#email="ngModel" name="email" [(ngModel)]="response.email"
class="form-control input-xs"/>
Thanks!

Changed value doesn't detect by up and down arrow of type="number"

I didn't do too much but up and down arrow doesn't detect the changes when we type number manually it bind with totalQuantity but if we tries to use down or up arrow which is inside input box, it doesn't detect that value is changed. It shows me previous value
<input type="number" name="quantity" [(ngModel)]="totalQuantity" />
Can you check this in stackblitz.
https://stackblitz.com/edit/angular-z1ntzg?file=src%2Fapp%2Fapp.module.ts

My form is not taking the default value

This may be a silly thing to ask but I have the following:
<input ng-model="product.quantity" min="1" type="number" id="quantity" name="quantity" value="1" />
But I can't get the form starts blank.
How can I ensure that the form will be filled with, at least a value of "1"?
The form value is being set by the ngModel value and will ignore the value attribute. Set your model!
$scope.product.quantity = 1;

Firefox: input field number min max not working

I'm facing the issue for input field's attributes min and max values in Firefox (v_30.0) browser.
This works
<input name="year" type="number" placeholder="YYYY" required min="1" max="12"/>
But this does not
<input name="year" type="number" placeholder="YYYY" required min="1990" max="20014"/>
it displays 1 on input box and does not move further.
Firefox (unlike Chrome) seems to follow the HTML5 definition for stepping up the value of an input type=number element. When the value is not set, as it here isn’t initially, it is interpreted as 0, so the result of incrementing is 1. Since it is outside the range, it is an invalid value, and further stepping is not possible.
This means that input type=number is intended for use with quantities for which an initial value can be set (or the default initial value of 0 can be accepted). After all, stepping up and down is really the reason for using this element type, and it needs to start somewhere.
Consequently, there is not much point in using required for such an element, unless the implicit default of 0 is acceptable and within the bounds set.
If you still want to use input type=number, you need to set some initial value with the value attribute that is within the bounds. Technically, this means that the pattern attribute has no effect.
To read a required 4-digit number when no default value is set, optionally with a placeholder, you can use a text input field with suitable attributes (but you cannot express a range requirement in HTML, in any reasonable way, in this approach):
<input name="year" type="text" placeholder="YYYY"
size="4" maxlength="4" pattern="\d[4}" required
style="font-family: Consolas, monospace">
Just set the starting value and it will work
<input name="year" type="number" min="1990" max="2014" value="1990" required />
http://jsfiddle.net/ywq6dq93/
EDIT:
As another user previously pointed out, this will not show the placeholder but instead the starting value of 1990. In Chrome it works to not set the value and still show the placeholder and achieve the desired functionality, however it seems that in FF you would need to set the value by javascript when focusing on the input field, if you want to show a placeholder instead of a starting value.
Demo for this: http://jsfiddle.net/1pg5727f
<input type="number" step="1" min="1" name="product_qty" value="1" title="Qty" class="input-text" size="4" maxlength="10" pattern="\d*" required />
if you still looking for the answer you can use input type="number".
min max work if it set in that order:
1-name
2-maxlength
3-size
4-min
5-max
just copy it
<input name="X" maxlength="3" size="2" min="1" max="100" type="number" />

HTML5 Range input with Ember

I have a range input I use to filter my model which is binded to the value attribute.
{{input type="range" class="range" name="range" min="0" max="64" value=bindvalue}}
The problem is that it filters for every step you drag the slider, instead of just filter the value when you release the slider. Which really makes the slider lag.
So I thought I could use this instead:
<input type="range" onchange="number.value=value" name="range" min="0" max="64" value="0">
{{input type="number" id="number" name="number" value=bindvalue}}
The range input sets the number inputs value on release but ember doesn't update my filter when this happens. only when I edit the number input myself.
How would you go about letting ember know when the range input sets the number inputs value?
Regarding your last approach and if not debounce is used, as stated here
Ember.js textField change event
the field needs to lose focus.
So you can do something like,
function updateNumberValue(value){
var num=document.querySelector("#number");
num.value=value;
$(num).blur();
}
http://emberjs.jsbin.com/fobep/1/edit