Questions tagged [angularjs-ng-model]

The ngModel directive in AngularJS binds an input, select, textarea (or custom form control) to a property on the scope using NgModelController, which is created and exposed by this directive.

ngModel is responsible for:

  • Instantiating the ngModelController
  • Binding the view into the model, which other directives such as input, textarea or select require.
  • Providing validation behavior (i.e. required, number, email, url).
  • Keeping the state of the control (valid/invalid, dirty/pristine, touched/untouched, validation errors).
  • Setting related CSS classes on the element (ng-valid, ng-invalid, ng-dirty, ng-pristine, ng-touched, ng-untouched) including animations.
  • Registering the control with its parent form.
  • Formatters, Parsers and View change listeners

Information from AngularJS API

See also

532 questions
5
votes
2 answers

AngularJS: ng-model setter inside ng-repeat

I've found some great answers on how to get the value of an ng-model inside an ng-repeat, but so far, I haven't found any that cover the setter. Suppose I have something like this:
5
votes
3 answers

Trigger ngModelController $parsers pipeline from a $watch

I'm writing a directive that requires ngModel and adds formatters and parsers to manipulate the value. It works great, but since the manipulation depends on external data I have to $watch, I'm looking for a way to update the model value from this…
hansmaad
  • 18,417
  • 9
  • 53
  • 94
5
votes
1 answer

ng-model outside controller

I'm trying to edit view outside ng-controller element. I was able to solve it by using $rootScope and dom manipulations, but I want to know how it can be solved by native angularjs? Html:
Webeith
  • 303
  • 1
  • 7
5
votes
1 answer

AngularJS ng-options get selected item as an object

I have an object array in my scope and I list them in a dropdown control like below.
4
votes
3 answers

Cannot clear form

I am trying to reset the form after the submit button is clicked. I understand that setting the form to pristine alone should not clear the input fields. I tried implementing the various suggestions to clear form by setting the form to pristine and…
dpm
  • 235
  • 2
  • 16
4
votes
2 answers

How select an item from dropdown list in angularjs?

How select an item from dropdown list in angularjs,Here I am using normal select list but not from object array. If I am using ng-repeat then I can select one, but here how can I do the same?
4
votes
2 answers

Why does setting ng-model to undefined not make the form/input valid again?

I have the following simple form with an type='email' input bound to a model:

Clearing ng-model

JTech
  • 3,420
  • 7
  • 44
  • 51
4
votes
1 answer

Why is my default radio button not showing up in the model?

I am have a pre-selected radio button on a form. Here is the html: The form shows up and the…
jhamm
  • 24,124
  • 39
  • 105
  • 179
1 2
3
35 36