Questions tagged [ngmodel]

Use ngmodel for questions related to the ng-model AngularJS directive.

The ngmodel directive is used for two-way data binding of form controls. It has a built-in controller named NgModelController which exposes and API which can be used for handling state changes and performing validation.

References

386 questions
6
votes
1 answer

Reactive forms in Angular: Two-way binding

I have a problem with Reactive forms. Updating the model class when the User changes the input is straight forward. But I need to do the opposite way: programmatically change the model, and see the changes in the HTML form. The simplified code…
Artur
  • 101
  • 1
  • 6
6
votes
2 answers

Angular2 ngModel change binding on Input type="number"

I have a number type input and when I try to change the value with an onChange event, it does not work. I've tried the same for a text input and it works perfectly.
Rob
  • 11,185
  • 10
  • 36
  • 54
5
votes
1 answer

Trying to set the cursor position inside a textbox after updating the model object

I want to set the cursor position after changing the model object but it actually tries to set the cursor position before updating the value of the textbox. HTML:
oksuzlerOmer
  • 125
  • 1
  • 2
  • 11
5
votes
1 answer

ng-select Get object as selected value from

I'm using ng-select (NgSelectModule from '@ng-select/ng-select')ץ This is my code:
Guy E
  • 1,775
  • 2
  • 27
  • 55
5
votes
2 answers

Angular testing and ngModel

I'm writing one of my first component test with Angular and I have some difficulties to make the ngModel binding work. Here is my test module definition: beforeEach(async(() => { TestBed.configureTestingModule({ declarations: [ …
Brice Argenson
  • 802
  • 2
  • 8
  • 13
5
votes
4 answers

How to set default selected values in multiselect with ngModel in Angular 2

How to set default selected values in multiselect. I get current_options and all_options from database and I want to update current_options and send new values do database again. Updating database works but when I refresh page none of options are…
pelcomppl
  • 575
  • 2
  • 6
  • 16
5
votes
2 answers

Angular 4: NgModel doesn't work. Does not set value to "date" field

Using Angular 4 I try to set a value to an Input of type "date" and I can not do it. The structure of my field is the following:
Luis
  • 2,006
  • 5
  • 31
  • 47
5
votes
3 answers

ngModel with dynamic variable

I am facing some problem when use ngModel to emit value to bump object with property get from bumpDetail.name array. I have pasted my code snippet down below. Could anyone please help me by checking it and tell me where I have done wrong? Thank…
Tri Nguyen
  • 397
  • 3
  • 5
  • 18
5
votes
2 answers

Testing two-way binding with ngModel in Angular2

I've read the documentation for testing two-way binding in Angular2. All examples are simple, too simple, actually. It seems like they only test the out-binding... I'll post some code to illustrate: import { Component, Input } from…
TBear
  • 93
  • 1
  • 7
3
votes
1 answer

Angular - TextArea with Multiple Binding

I have two input field ("name" and "city") and one textarea on my screen. Text area is filled up with some JSON data and data contains a few details like "name", "city", "address", "pin code" etc. How do I only update "name" or "city" inside…
Kanchan
  • 1,609
  • 3
  • 22
  • 37
3
votes
1 answer

Issue with cursor going to the end on ngModelChange Angular/Typescript

I'm having an issue with my HTML input field and the typescript component that is using ngModelChange. I want to be able to edit the input value wherever I need to. For example: original input is auto-filled with is "00:00:00". I want to edit it to…
andopr
  • 316
  • 3
  • 9
3
votes
2 answers

nativeElement.Value changes in directive not being reflected for input/ngModelChange events at the moment

Trying to replace a special character of input, I ended up writing this simple directive: normalized-input.directive.ts @Directive({ selector: "[appNormalizedInput]" }) export class NormalizedInputDirective { constructor(private element:…
3
votes
2 answers

Data Binding with [ngModel] not working Angular 6

I just created an empty Angular project on IntelliJ, I'm trying to bind a textbox to an object's member. My object stays undefined or whatever I assign to it inside OnInit. I included FormsModule in the app.module.ts and I can't get it to work. This…
oksuzlerOmer
  • 125
  • 1
  • 2
  • 11
3
votes
1 answer

ngModel two-way-data-binding of object properties in ngFor over object keys

I'm using angular6 and I'm trying to loop over the properties of an object, which i load in advance, to show them in text fields. The properties are supposed to be changeable. Therefore i need a two-way-binding. I tried:
S14p
  • 51
  • 1
  • 7
3
votes
2 answers

Angular input event is not fired by setting the value with the model

I use a input field which calls a method when the value in it changes. But when I set the value in the input field by the ngModel (not typed by hand) the "value changed" event of the input field will not be fired. Input field:
WeSt
  • 889
  • 5
  • 14
  • 32
1
2
3
25 26