FAQ Database Discussion Community


Ng-model not working on dynamically added html controls

javascript,angularjs,angularjs-ng-repeat,angular-ngmodel
I am trying to preselect the selects with same ng-model but when I add an item in $scope.alertConditions.rows the selects are not pre-selected based on ng-model. Any help is appreciated. HTML: <div class="alert_center_table_body" ng-repeat="alertCondition in alertConditions.rows track by $index"> <div></div> <div> <select ng-model="alertConditions.run_alert" ng-change="getRunDates(alertConditions.run_alert, $index)"> <option ng-repeat="run_alert in runAlerts"...

Multiple instances of custom directive, confusion with ngModel

angularjs,angularjs-directive,angular-ngmodel
I've created a custom directive to render a slider for a question (essentially wrapping jquery ui slider). The directive takes an ngModel and updates it when the user uses the slider, and there's a $watch attached to the parent model (the ngModel passed to the directive is only a part...

AngularJS $scope values from ng-model lost from page to page in same controller - Ionic Framework

angularjs,angularjs-scope,ionic-framework,ionic,angular-ngmodel
I have this page which links the input.countNum scope variable to the input with ng-model. The value which is displayed on the button shows fine. When you click the button on the first page, it navigates to the second page which also displays the scope variable. But the variable is...

angularjs: custom directive to check if a username exists

angularjs,angularjs-directive,angular-ngmodel
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',...

Updating a value based on a range of inputs in AngularJS

javascript,angularjs,angularjs-ng-repeat,angular-ngmodel
What I am essentially trying to achieve here is to have a remaining amount that decreases in amount as the user enters the amount in to a series of text fields. These text fields are generated by an angular loop and its the remainingAmount var that I need to be...

Not getting the updated value of ng-model when ng-model is changed programaticaly

angularjs,angular-ngmodel
When I check master check-box all the children check-box should be checked and their content should also be shown when check-box is checked otherwise their content should not be shown but the issue is that child check-boxes are checked but their content is not shown when I check master check-box...

AngularJs - ng-model in a SELECT

javascript,jquery,angularjs,angular-ngmodel
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...

ng-model issue on logic

javascript,angularjs,angular-ngmodel
I have a little issue with an ng-model I am working on. First I will show the part where the ng-model is working properly <input type="text" ng-model="slip.risk" ng-change="riskWinCalculations(slip, 'RISKSTRAIGHT')"> <input type="text" ng-model="slip.win" ng-change="riskWinCalculations(slip, 'WINSTRAIGHT')"> <strong>To Win: </strong>{{straightTotalWin | currency}} <strong>Total Stake: </strong>{{straightTotalStake | currency}} now the html where the ng-model...

AngularJS adding incremental numbers to a select list

javascript,angularjs,angular-ngmodel,ng-options
I want a select box where I can choose from a list with a min/max number. Currently my number is just 1 to 10 so I have the below. <body ng-app="demoApp"> <div ng-controller="DemoController"> <select ng-model="selectedItem" ng-options="opt as opt for opt in options"> </select> The value selected is {{ selectedItem }}....

How do I bind the same data to different options using angulajs?

angularjs,ionic-framework,ionic,angular-ngmodel
I'm trying to select data and bind it to a specific item, however once I select the data, all of my items are now bound to the selected data. How can I select specific data to each of my items. here is my demo. http://play.ionic.io/app/cb25b106e671...

Specifying Angular ngModel Value with ng-repeated options

javascript,angularjs,angularjs-scope,angularjs-ng-repeat,angular-ngmodel
I've got a select dropdown, whose options are being ng-repeated out of an object called $scope.bars. However, my ng-model, which is set to a sub-value of $scope.bars, is not correctly choosing an option. Instead, the select box is blank by default, indicating an 'undefined' value. Here's my HTML: <div ng-app="programApp"...

How to populate table with json data using angular?

javascript,json,angularjs,angular-ngmodel
I have loaded the json data successfully via http but having a problem populating a table with this json data based on the entered value 'name'. Plunker Below. Plunker json [ { "name": "Tim", "address": "Road", "phone": "1234", "status": "busy" }, { "name": "Sue", "address": "Street", "phone": "4321", "status": "available"...

Do I need 2 ng-models for this?

javascript,angularjs,angular-ngmodel
I'm trying to create a form where the input fields are populated with values from an array, but the form is saved into a different array. For example the fields would be populated from this array { "organisation": [ { "OrgID": 1234, "OrgName": "Organisation one" }, { "OrgID": 4567, "OrgName":...

ngOption default selected option

angularjs,angular-ngmodel,angular-services,angularjs-ng-options
How to have a default option in select box...I tried several options and do not get it I tried creating a scope on my contralador with the value of the object that comes from json: Like this: $scope.productSelect = $scope.item[0]; this my code: html: <select id="variant" class="form-control variant-select" ng-model="productSelect" ng-options="product...

Using ng-model with select to show data attribute instead of value?

javascript,html,angularjs,angular-ngmodel
I currently have a simple select list that contains both data attributes and a value: <select ng-model="myList"> <option value="1" data-name="Test name 1">Option 1</option> <option value="2" data-name="Test name 2">Option 2</option> <option value="3" data-name="Test name 3">Option 3</option> </select> <div id="displaySelected"> {{myList}} </div> Inside my div (with the ID of displaySelected), it is...

Two inputs with one way binding in ng-model

javascript,angularjs,angularjs-directive,angularjs-scope,angular-ngmodel
I try to make an application which have two inputs text (say parent and child) , each one has ng-model . I want to make it one way binding , mean , change in the parent input should display the same value in the child , and change in the...

pass the ng-model value to angular directive

javascript,angularjs,angularjs-directive,angular-ngmodel
I have a scenario where I have certain number of text-boxes and when I click on any of the text-box, its corresponding ng-model is to be printed on the browser console. I have written the following angular code: <html ng-app="myApp"> <head> <script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.4.0-beta.0/angular.min.js"></script> <script> var app = angular.module("myApp", []) app.controller("myAppCtrl",...

AngularJS Show List Items based on ng-model

angularjs,angular-ngmodel
I'm trying to create some functionality where the user would have an input box and all the data (li's) below are hidden. Then when a user types into the input box, those li's that match that text are show. What would the best way to do this using angular? I've...

Getting Select box value in Angular - without using ng-options?

angularjs,angular-ngmodel
I'm trying to modify a form which is using a select box that is populate NOT using ng-options. The form itself is bound to an angular controller. Is there still a way for me to know the selected value of the select box even though the select values were not...

Angular Js ng-model not updating variable in an inner function

angularjs,angular-ngmodel
I have the following code in my controller: appControllers.controller('myCtrl', [ '$scope', function($scope) { $scope.timeFreeze = false; $scope.ws = new WebSocket("ws://localhost:8080/ws"); $scope.ws.onopen = function() { $scope.ws.send('{...}'); }; $scope.ws.onmessage = function (evt) { var received_msg = JSON.parse(evt.data); //...do something with the data... console.log($scope.timeFreeze); // This is ALWAYS false!!! Why? if ( $scope.timeFreeze...

ngModel Changing to Child Scope

angularjs,angular-ngmodel
When I edit a value through an input field that is bound (perhaps bound isn't the right term) to a parent controller's scope, it seems to re-bind to the child controller's scope. This eliminates my ability to affect the value with functions built into the parent scope (clicking the button...

Change selected