angular-ngmodel

Angular JS - get selected text as ng model (without ng-options)

扶醉桌前 提交于 2019-12-13 23:51:28
问题 In my code behind, I fill up a DropDownList as follows (using VB) ddlCountries.DataSource = dt ' dt is DataTable with columns "CountryCode" and "CountryName" ddlCountries.DataTextField = "CountryName" ddlCountries.DataValueField = "CountryCode" ddlCountries.DataBind() ddlCountries.Attributes.Add("ng-model", "CountryName") Then client side, I have a select tag, which is filled with options from server side as below: <select ng-model="CountryName"> <option value="IN">India</option> <option

Update HTML input value changes in angular ng-model

久未见 提交于 2019-12-13 15:46:04
问题 I have some ng-model input elements that gets updated non-angularJS functions like jquery or sometimes by pure javascript DOM apis. The value on the html input element changes however the model scope variable doesn't get updated. Is there any way to force angular to process these updates app.js After a time-out of 5secs, the value 1 is changed to 999. This is reflected in html but not in $scope.val angular.module('inputExample', []) .controller('ExampleController', ['$scope', '$timeout'

Angularjs - after I enter a value into a <intput> field with ng-model the value changes to undefined

ⅰ亾dé卋堺 提交于 2019-12-13 08:18:35
问题 I have a simple form that accepts an input. For some reason when I change the value the scope variable changes to undefined. <body ng-controller="myctrler"> <input ng-model="t.unsubscribeEmail" type="email" class="textboxfields" placeholder="Enter email address"> </body> In the controller: $scope.k= { unsubscribeEmail : "not" }; The value before I enter anything into the inputbox is "not". As soon as I type something in the input the value changes to undefined. What am I missing? 回答1: Change

ngModel needs $parent when within Transcluded html

佐手、 提交于 2019-12-13 04:47:24
问题 I have a directive for a input field that uses transclusion to take the elements that are enclosed in the directives element which includes an ng-model attribute. After reading countless SO questions and Angular documentation to find out how to get the ng-model in the transcluded html to sync with the ng-model in my directive I finally stumbled stumbled upon a trick to get it to work. That is to use $parent where the ng-model is within the input field. This is all fine and dandy, however, it

Dynamic Radio Buttons 2 Way Binding using ngModel - Angular 6

牧云@^-^@ 提交于 2019-12-13 02:56:17
问题 I'm generating dynamic radio buttons which will all be consolidated on form submit not individually. I however need to bind them to a particular value in my component individually which I have no clue how to do. I've seen the other related posts on this subject on stackoverflow but none of them seem to help me out. Here's my code: <input type="radio" class="one" id="{{ i }}_{{ candidate.user._id }}_{{post.id}}_{{ candidate.date}}" name="{{post.id}}" [value]='candidate.user._id' [(ngModel)]=

Ng-model with Cookie

痞子三分冷 提交于 2019-12-13 00:15:33
问题 I'm trying to take the first example from the angular.js homepage and adding in cookie support. This is what I have so far: https://jsfiddle.net/y7dxa6n8/8/ It is: <div ng-app="myApp"> <div ng-controller="MyController as mc"> <label>Name:</label> <input type="text" ng-model="mc.user" placeholder="Enter a name here"> <hr> <h1>Hello {{mc.user}}!</h1> </div> </div> var myApp = angular.module('myApp', ['ngCookies']); myApp.controller('MyController', [function($cookies) { this.getCookieValue =

ngFor and ngModel resseting input when pushing into array

こ雲淡風輕ζ 提交于 2019-12-12 14:21:31
问题 I'm trying to create a form where you can add multiple lines before sending it. For that I'm using storing data in an array of Lines and use ngFor and ngModel to bind / retrieve data into my form. Here is what my code looks like export class MyComponent implements OnInit { lines : Line[] = []; constructor() { } ngOnInit() { this.lines.push(new Line("XXXXXX1",0,0)); } addLine(){ let line = (new Line("XXXXXX1",0,0)); this.lines.push(line); } save(){ console.log(this.lines); } } class Line {

Set model value programmatically in Angular.js

China☆狼群 提交于 2019-12-12 09:52:11
问题 I'm an author of angular-input-modified directive. This directive is used to track model's value and allows to check whether the value was modified and also provides reset() function to change value back to the initial state. Right now, model's initial value is stored in the ngModelController.masterValue property and ngModelController.reset() function is provided. Please see the implementation. I'm using the following statement: eval('$scope.' + modelPath + ' = modelCtrl.masterValue;'); in

Using expressions in ngModel in Angular.js

六月ゝ 毕业季﹏ 提交于 2019-12-12 07:49:12
问题 Giving the code inside of my controller: $scope.entity = { firstName: 'Jack', lastName: 'Bauer', location: { city: 'New York' } }; $scope.path = 'location.city'; How do I dynamically bind ngModel to the property of the entity specified by path ? I've tried something like this, but to no avail: <input ng-model="'entity.' + path"> 回答1: Slava, I'm not too sure if this is a good idea to begin with. But anyhow, You need to make your model getterSetter aware by adding this property to your input ng

Angular model.$viewValue not showing in input field

亡梦爱人 提交于 2019-12-12 01:59:11
问题 I previously write this [question][1], Inow I have the problem that the model.$viewValue it's not the same of the value the i see in the input box. <div amount-input-currency="" ng-model="data.amount" ></div> This is my directive (isNumeric and similar is not important that works weel): var app = angular.module('plunker', []); app.controller('MainCtrl', function($scope) { $scope.data = { amount: ''}; }); app.directive('amountInputCurrency', function () { return { restrict: 'EA', require: