angular-ngmodel

Angularjs: select not updating when ng-model is updated

你。 提交于 2019-11-27 01:26:24
问题 I've created the following example so you can see exactly what is happening: http://jsfiddle.net/8t2Ln/101/ The same thing happens if I use ng-options. I have a different reason for doing it this way, but for the simplification of the example left that part out. As you can see it has by default two options. I'm displaying the selected value of the ng-model next to the select so you can see what it is. When you use the top piece to add a third option it sets the value to the value of that new

How to detect bootstrap datetimepicker change events within angular2

自闭症网瘾萝莉.ら 提交于 2019-11-27 01:22:49
问题 I am using the bootstrap datetimepicker in angular 2 https://eonasdan.github.io/bootstrap-datetimepicker/ In my template i have: <div class='input-group date datepicker'> <input type='text' class="form-control" [(ngModel)]="date"> <span class="input-group-addon"> <span class="glyphicon glyphicon-calendar" (click)="getCalendar()"></span> </span> {{date}} </div> The problem is when I select a date on the calendar by click, it does not trigger any "change" event (in other words, ngModel is not

AngularJS checkbox filter

雨燕双飞 提交于 2019-11-26 19:12:59
问题 I would like to filter the results. There is a list of wines, my wish is when no checkbox is checked, the entire list of wine is displayed. when only 1 checkbox is checked is displayed the related category when more than one checkbox are checked the related categories are displayed I'm a newbie to AngularJS, I tried with ng-model wihout success, here is the code without ng-model associated to the function: <html ng-app="exampleApp"> <head> <title></title> <script src="https://ajax.googleapis

AngularJS : ng-model binding not updating when changed with jQuery

孤人 提交于 2019-11-26 18:27:35
This is my HTML: <input id="selectedDueDate" type="text" ng-model="selectedDate" /> When I type into the box, the model is updated via the 2-way-binding mechanism. Sweet. However when I do this via JQuery... $('#selectedDueDate').val(dateText); It doesn't update the model. Why? Renan Tomal Fernandes Angular doesn't know about that change. For this you should call $scope.$digest() or make the change inside of $scope.$apply() : $scope.$apply(function() { // every changes goes here $('#selectedDueDate').val(dateText); }); See this to better understand dirty-checking UPDATE : Here is an example

Contenteditable with ng-model doesn't work

穿精又带淫゛_ 提交于 2019-11-26 16:36:14
问题 I'm trying to store the value of a contenteditable to my JS code. But I can't find out why ng-model doesn't work in this case. <div ng-app="Demo" ng-controller="main"> <input ng-model="inputValue"></input> <div>{{inputValue}}</div> // Works fine with an input <hr/> <div contenteditable="true" ng-model="contentValue"></div> <div>{{contentValue}}</div> // Doesn't work with a contenteditable </div> Is there a workaround to do that ? See : JSFiddle Note: I'm creating a Text editor, so the user

angularjs: custom directive to check if a username exists

女生的网名这么多〃 提交于 2019-11-26 14:30:48
问题 I have my registration form with textbox username. I want to do is when the user enter the username, the custom directive will check if the entered username is exists in the database. directives.js angular.module('installApp').directive('pwCheck', function ($http) { return { require: 'ngModel', link: function (scope, elem, attrs, ctrl) { elem.on('blur', function (evt) { scope.$apply(function () { $http({ method: 'GET', url: '../api/v1/users', data: { username:elem.val(), dbField:attrs

Ng-model does not update controller value

北慕城南 提交于 2019-11-26 13:57:14
Probably silly question, but I have my html form with simple input and button: <input type="text" ng-model="searchText" /> <button ng-click="check()">Check!</button> {{ searchText }} Then in the controller (template and controller are called from routeProvider): $scope.check = function () { console.log($scope.searchText); } Why do I see the view updated correctly but undefined in the console when clicking the button? Thanks! Update: Seems like I have actually solved that issue (before had to come up with some workarounds) with: Only had to change my property name from searchText to search.text

ngModel Formatters and Parsers

微笑、不失礼 提交于 2019-11-26 11:33:18
I posted the same question in different form, but no one answered. I am not getting a clear picture of what the Formatters and Parsers do in angular js. By the definition, both the Formatters and Parsers look similar to me. Maybe I am wrong, as I am new to this angularjs. Formatters Definition Array of functions to execute, as a pipeline, whenever the model value changes. Each function is called, in turn, passing the value through to the next. Used to format / convert values for display in the control and validation. Parsers Definition Array of functions to execute, as a pipeline, whenever the

What&#39;s the difference between ng-model and ng-bind

a 夏天 提交于 2019-11-26 10:58:38
I'm currently learning AngularJS and am having difficulty understanding the difference between ng-bind and ng-model . Can anyone tell me how they differ and when one should be used over the other? Tosh ng-bind has one-way data binding ($scope --> view). It has a shortcut {{ val }} which displays the scope value $scope.val inserted into html where val is a variable name. ng-model is intended to be put inside of form elements and has two-way data binding ($scope --> view and view --> $scope) e.g. <input ng-model="val"/> . tosh 's answer gets to the heart of the question nicely. Here's some

AngularJS : ng-model binding not updating when changed with jQuery

走远了吗. 提交于 2019-11-26 06:18:43
问题 This is my HTML: <input id=\"selectedDueDate\" type=\"text\" ng-model=\"selectedDate\" /> When I type into the box, the model is updated via the 2-way-binding mechanism. Sweet. However when I do this via JQuery... $(\'#selectedDueDate\').val(dateText); It doesn\'t update the model. Why? 回答1: Angular doesn't know about that change. For this you should call $scope.$digest() or make the change inside of $scope.$apply() : $scope.$apply(function() { // every changes goes here $('#selectedDueDate')