Questions tagged [angularjs-model]

The ngModel directive 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.

From Angularjs documentation:

The ngModel directive 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.

90 questions
45
votes
5 answers

AngularJS - how to change the value of ngModel in custom directive?

Lets take a look to my directive: angular.module('main').directive('datepicker', [ function() { return { require: '?ngModel', link: function(scope, element, attributes, ngModel) { ngModel.$modelValue = 'abc'; // this…
Sady
  • 451
  • 1
  • 4
  • 4
18
votes
1 answer

Consider a form invalid while async validator promises are pending

I have an async validator: app.directive('validateBar', ['$http', function($http) { function link($scope, $element, $attrs, ngModel) { ngModel.$asyncValidators.myValidator = function(value) { return $http.get('/endpoint/' +…
Blaise
  • 13,139
  • 9
  • 69
  • 97
16
votes
3 answers

Why is Angularjs ng-pattern not working with the following regexp?

For some reason the initialized value doesn't appear in the field, but the second field without the ng-pattern does work. any ideas? angular.module('app', []).controller('MainCtrl', function($scope) { $scope.widget = {title: 'abc', title2:…
Will
  • 271
  • 1
  • 3
  • 12
7
votes
2 answers

AngularJS orderby doesn't work when orderby-property is edited

I have a list of objects in my scope and want to iterate over them, show some of their properties in ordered-by-some-property way and change them. ng-repeat is used to display textboxes binded to each object of my list and orderby filter which takes…
6
votes
2 answers

angularJS element.on callback and scope.$apply

In this example, I have an input with an attached directive. The directive is meant to display messages next to the input. There's another input and a button to add messages. Once some messages are displayed, focusing on the input with the attached…
David V.
  • 5,708
  • 3
  • 27
  • 27
5
votes
2 answers

Create ng-model dynamically with {{expression}} doesn't work?

I am working on an angular project where I need to create a form based on an array of questions. I would like to create ng-model for each question in the array. So I have come up with something like the following, but it is not working.
loveNZ
  • 307
  • 2
  • 12
4
votes
3 answers

Angularjs updates the view but not the model

please pay attention this is the opposite of 99% of the related questions on stackoverflow. Mi problem is: I have a dependent select, when the 'Master' select changes, the 'Slave' view gets updated but NOT it's model. WEIRD. Example code:
Daniel
  • 1,287
  • 12
  • 12
4
votes
2 answers

Parser function does not get called for change in input textbox

I am new to parsers and formatters. I have a directive that will be doing validation on change of the model.One way to do this is the $watch but from what I understand that is not a good way since it allows the model to be updated. So I was looking…
Abhik
  • 1,920
  • 7
  • 27
  • 50
3
votes
1 answer

AngularJS ngModelOptions updateOn 'submit' validateOn 'default'

Is there any way how to trigger validation when using ngModelOptions? My use-case is to have a form with all fields updating the ngModel on submit (due to the fact that I would like to revert the whole form when user clicks on Cancel button). Having…
kuceram
  • 3,795
  • 9
  • 34
  • 54
2
votes
1 answer

How to add/remove item to/from list in ionic

I have create tabbed ionic application in VS2015. Now I want to add there simple list with possibility add/remove items (something similar to this - sample of angularjs app) My HTML code (tab-chats.html):
RredCat
  • 5,259
  • 5
  • 60
  • 100
2
votes
1 answer

ng-model does not work in select directive

What is working: The ng-options contains all names and it is shown in the dropdown-list. Problem: At the beginning if nothing is selected, there should the text "Select name..." displayed. But it's empty right now. I know it has been asked a lot…
Marcel Tinner
  • 1,343
  • 11
  • 18
2
votes
0 answers

CKEditor prevents framework's and native events propagation

I am having an angular directive that is compiled and inserted into CKEditor. Furthermore i have a widget plugin that upcasts those directives to widgets and allows few of their fields for editing. In those fields there is bound to a model…
radpet
  • 701
  • 1
  • 5
  • 16
2
votes
4 answers

AngularJs - model value does not reflect on ui in nested controllers case

I am using angularjs for one of the my module in application. I want to update UI of various locations on page, so that all ui components will work synchronously as the model value changes. here is my html-
Shekhar
  • 416
  • 2
  • 5
  • 13
2
votes
2 answers

Angularjs debounce for multiple events not working

I was looking at the Angular documentation for handling forms and found a very useful example for capturing the update in any field/control with a delay. Following is the sample code provided by Angularjs:
Haider
  • 1,488
  • 2
  • 15
  • 29
2
votes
1 answer

Get the selected text (not value) of select element in angular

For example I would like to do something like this:
Simon Bengtsson
  • 7,573
  • 3
  • 58
  • 87
1
2 3 4 5 6