angular-ngmodel

setViewValue in directive on input not updating actual visible input value

心不动则不痛 提交于 2019-12-20 11:09:14
问题 I've been fighting with this for almost two days. I hope you guys can help me. Summary: I have problems setting the view value of some input fields programatically. I have a form with inputs whose values are saved before the form is removed (multiple elements and multiple forms possible, user might close a form, and reopen later). On reopening the form I want to restore the previous view values (main reason is to get back also the invalid view values which were not saved in the model). This

What is purpose of using forRoot in NgModule?

限于喜欢 提交于 2019-12-20 09:11:10
问题 What is the purpose of using forRoot in NgModule? Is it same as the providers in AngularJS 1.x? How does it play the significant role in lazy loading? TIA. 回答1: It has to do with singletons. Angular services are loaded onto the page 1 time (singleton) and all references point back to this 1 instance. There is a risk that a lazy loaded module will try to create a 2nd instance of what should be a singleton, and the forRoot() method is a way to ensure that the app module / shared module / and

AngularJS ng-value and ng-model do not work together [duplicate]

被刻印的时光 ゝ 提交于 2019-12-20 06:22:15
问题 This question already has answers here : What's the difference/incompatibility between ng-model and ng-value? (5 answers) Closed 5 months ago . I was trying to give a value to textfield using ngvalue and textarea has that value but it when I submit it, it recognized as textarea is empty. <textarea ng-value="main.record.basic_info.application_letter" class="form-control" ng-model="main.record.apply_job.cover_letter" name="name" rows="15" cols="80" style="resize: none"> </textarea> 回答1: You

How do I get the ng-model of a select tag to get the initially-selected option?

大兔子大兔子 提交于 2019-12-19 08:13:03
问题 I'm pretty new to Angular, so I may be going about this all wrong... I have a <select> similar to the following: <select ng-model="mySelectedValue"> <option value="">--</option> <option ng-repeat="myValue in someDynamicArrayOfValues" value="{{myValue}}" ng-selected="myFunctionForDeterminingWhetherValueIsSelected(myValue)">{{myValue}}</option> </select> This mostly works... The dropdown initially renders with the correct option selected, and if I change the selected option, then

Angular - ngModel not updating when called inside ngInclude

让人想犯罪 __ 提交于 2019-12-18 18:48:10
问题 First and foremost, the plunker: http://plnkr.co/edit/v1uTz5 This is a working demo of the issue I am running into. I have a ng-include to include a partial. Inside the partial I have an text input with ngModel AND directive. The model updates accordingly inside the include, but any interaction outside the include is ignored. The {{test}} outside the include doesn't update, but the {{test}} inside does. The directive, when called, handles the enter key and calls the correct scope and function

Get user input from textarea

╄→гoц情女王★ 提交于 2019-12-18 11:06:06
问题 I'm new to angular2. I want to store user input from a text area in a variable in my component so I can apply some logic to this input. I tried ngModel but it doesn't work. My code for the textarea: <textarea cols="30" rows="4" [(ngModel)] = "str"></textarea> And inside my component: str: string; //some logic on str But I don't get any value in str inside my component. Is there an error with the way I'm using ngModule ? 回答1: <pre> <input type="text" #titleInput> <button type="submit" (click)

Dynamically update ion.rangeSlider ngModel in AngularJS directive

独自空忆成欢 提交于 2019-12-18 07:08:44
问题 I'm trying to update the value of an Ion.RangeSlider when its bound ng-model scope variable changes. The model updates when the Ion.RangeSlider is used, but not vice-versa. Other inputs with the same ng-model update when the model value changes, so this must be some special case. Edit: Woo! Here's a snippet @lin :) Also jsfiddle. var app = angular.module('ngModelIonRangeSliderDemo', []); app.controller('MainCtrl', function ($scope, $rootScope, $timeout) { $scope.someNumber = 10; }).directive(

angular 6 warning for using formControlName and ngModel

◇◆丶佛笑我妖孽 提交于 2019-12-17 17:36:42
问题 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

Angular bootstrap datepicker date format does not format ng-model value

喜夏-厌秋 提交于 2019-12-17 08:56:09
问题 I am using bootstrap date-picker in my angular application. However when I select a date from that date-picker underlying ng-model that I have bind gets updated I want that ng-model in one date format 'MM/dd/yyyy'. but it every times makes date like this "2009-02-03T18:30:00.000Z" instead of 02/04/2009 I have created a plunkr for the same plunkr link My Html and controller code is like below <!doctype html> <html ng-app="plunker"> <head> <script src="//ajax.googleapis.com/ajax/libs/angularjs

Using ng-repeat to generate select options (with Demo)

老子叫甜甜 提交于 2019-12-17 07:53:21
问题 controller: $scope.send_index = function(event, val){ console.log(val); $scope.variable = 'vm.areas['+val+'].name'; console.log( $scope.variable ); }; and this is in the view: <select ng-model="vm.areas"> <option ng-repeat="area in vm.areas" ng-value="area" id="{{area}}" ng-click="send_index($event, $index)">{{area.name}} </select> <input value="{{variable}}"> where "vm" is my model. Expression inside of an expression (Angular) my problem is that i need to have an {{array[]}}, with the index