angular-ngmodel

Setting ngTrueValue and ngFalseValue to numbers

陌路散爱 提交于 2019-11-28 23:40:32
问题 Update : question is obsolete for latest Angular version, see tsh's comment on this post I have bound a checkbox to a value: <input type="checkbox" ng-model="checkbox" ng-true-value="1" ng-false-value="0" /> The value of the checkbox is set to 1 in the controller: function Controller($scope) { $scope.checkbox = 1 } However, initially the checkbox does not appear checked. If I change the initial value of $scope.checkbox to "1" , it does. (jsfiddle demo) I have tried all kinds of variations: ng

What is the purpose of the new built in 'parse' validation key in Angular 1.3?

烈酒焚心 提交于 2019-11-28 21:39:39
The behavior of the ngModelController parsing pipeline seems to have changed between Angular 1.2 and 1.3. I now always see a new validation key named 'parse' added to all $error objects, and whenever one of the parsers returns undefined, it overrides/replaces all other validation keys that may have been already set. For instance, here is a working example in Angular 1.2.23 - try entering a number out of range: http://jsfiddle.net/8doq0saf/5/ The same thing running under 1.3-rc gives a different result: http://jsfiddle.net/1t52s9b2/4/ I have not yet been able to find any documentation on this

ng-model no longer updates after typing into text input

Deadly 提交于 2019-11-28 18:39:07
I am new to AngularJS and I am having a problem that I am having trouble solving, there was a similar question on stackoverflow but it didn't seem to help me out. I basically have a form that gets updated by ng-click, but once once I enter text into any of the text boxes, those text boxes no longer update. This is my HTML Edit Course: <li ng-repeat="course in courses"> <p> <a ng-click="Edit_Course(course.id)">{{course.course_name}}</a> </p> </li> <div ng-show="showedit == 1"> <form novalidate ng-submit="edit_course()" class="simple-form"> <label for="form_course_name">Course</label> <input

angular 6 warning for using formControlName and ngModel

本秂侑毒 提交于 2019-11-28 17:14:21
I recently upgraded the angular version to 6-rc. I got following warning It looks like you're using ngModel on the same form field as formControlName. Support for using the ngModel input property and ngModelChange event with reactive form directives has been deprecated in Angular v6 and will be removed in Angular v7 For more information on this, see our API docs here: https://angular.io/api/forms/FormControlName#use-with-ngmodel What does it say exactly? the link does not have any fragment for #use-with-ngmodel I guess I need to remove ngModel and use formGroup as my data binding object. If

AngularJs - ng-model in a SELECT

白昼怎懂夜的黑 提交于 2019-11-28 16:59:11
问题 JSfiddle Problem: I have a SELECT-element in my page, which is filled in with an ng-repeat . It also has a ng-model which has a default value. When I change the value, the ng-model adapts, that's ok. But the dropdown-list shows an empty slot at launch, where it should have the item with the default value selected instead. Code <div ng-app ng-controller="myCtrl"> <select class="form-control" ng-change="unitChanged()" ng-model="data.unit"> <option ng-repeat="item in units" ng-value="item.id">{

How can I make angularjs ngChange handler be called only when user finishes typing

一个人想着一个人 提交于 2019-11-28 16:11:21
I have an input field, where I want to apply the variant of ngChange . The input field is sort of binding with an ajax call, when user changes the input, the server side will process the data, however, I don't wanna make the call too often. Say the user wanna input a really string, I want the call be made only after user finishes the word he is about to type. Nevertheless, I don't wanna use event such as blur. What would be a better way to implement this, rather than setTimeout ? Use ng-model-options in Angular > 1.3 <input type="text" ng-model="vm.searchTerm" ng-change="vm.search(vm

setting initial value using ngModel for select dropdown

一世执手 提交于 2019-11-28 14:23:36
I have an array of tranTypes (transaction types) that are loaded into a dropdown. After the user selects a value and navigates to another component upon returning the value is not selected in the dropdown. From other readings, I've learned this is b/c the objects are not the same instance. What do I do in this situation then? <select name="tranType" class="form-control" [(ngModel)]="model.tranType" required> <option *ngFor="let tranType of tranTypes" [ngValue]="tranType">{{tranType.desc}}</option> </select> Solution ngOnInit(): void { this.myService.getTranTypes() .subscribe(tranTypes => {

Angularjs: select not updating when ng-model is updated

北战南征 提交于 2019-11-28 06:40:39
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 option as is evidenced by the displayed ng-model value next to the select, but the select itself doesn

How to detect bootstrap datetimepicker change events within angular2

对着背影说爱祢 提交于 2019-11-28 06:30:39
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 fired). If i type in the text box, then the {{date}} shows me the value plus the text i typed. How can I

Angular 2: How to get the selected value from different options of a form?

烂漫一生 提交于 2019-11-27 22:13:53
问题 I would like to use a <select> in a form to let the user being able to update values among different <option> . I have used the technique from the guide here: https://angular.io/docs/ts/latest/guide/forms.html. Here is the sample I am talking about: <div class="form-group"> <label for="type">Type :</label> <select class="form-control" [(ngModel)]="order.type" ngControl="type"> <option *ngFor="#type of types" [value]="type">{{type}}</option> </select> </div> In my order-details.component I