FAQ Database Discussion Community


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...

angularjs update model based on sum of other fields

javascript,angularjs,angular-ngmodel
I want to be able to update a value in my data model based on the result of two other fields. using <td><input ng-value="s.hours*s.rate"></td> I have no problem calculating the result but how am I able to bind it to toal? eg I tried <td><input ng-model="s.total" ng-value="s.hours*s.rate"></td> but the model...

Having trouble using ngChange to update model

javascript,angularjs,angular-ngmodel,angularjs-ng-change,ng-controller
I just started learning the basics of Angular. I'm attempting to making an annual salary converter, just for fun. I'm having difficulty with my monthly ng-model updating when the yearly model is changed by the user. The fields are input tags. Here is the code <!doctype html> <html ng-app="salaryApp"> <head>...

Select not selecting when binding with ng-model and ng-options

javascript,angularjs,select,angular-ngmodel,ng-options
Here's my select: <select class="form-control" ng-options="assistanceType as assistanceType.name for assistanceType in assistanceTypes" ng-model="selectedRecord.assistanceType"></select> Here's what I'm using to load the Assistance Types: $scope.getAssistanceTypes = function () { $http.get('/api/assistanceType/getAll'). success(function (data, status, headers, config) { $scope.assistanceTypes = data; }). error(function (data, status, headers, config) { alert(data.ExceptionMessage); }); } Here's the result:...

Angular query on mobile

javascript,angularjs,angular-ngmodel
Simply I am using ng-model="query" on my project as a search. It works great but for some reason it won't work on mobile (specifically iphone 5s). Is there any reason for this? I have tried searching for answers on google and haven't come up with anything.

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...

How to programmatically uncheck checkbox?

angularjs,checkbox,angular-ngmodel
I want to programmatically uncheck a checkbox. I know how to it in javascript but since I'm using angular, i think it's different. Here's the link of jsfiddle : https://jsfiddle.net/TKVH6/499/ This is the first time I used jsfiddle so please let me know if you cant see the script and...

Angular ng-model on input not binding within ng-repeat

angularjs,angularjs-ng-repeat,angular-ngmodel
I'm trying to get the input entry {{post.title}} to post upon submit, but only {{post.upvotes}} is posting. Can anyone see what I might not be seeing in my code? The result when I submit is - upvotes: 0 When I change {{post.title}} to {{title}}, it posts fine, but I can't...

ng-model throwing error on input type number in angular 1.3

javascript,angularjs,html5,angular-ngmodel
I have an input field which I want he user to input a number, so I have made an input field with type="number". When I use it in 1.2 I get no errors <script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.27/angular.min.js"></script> <script> var app = angular.module('app', []); app.controller('MainCtrl', ['$scope', function ($scope) { $scope.person = [ {"name":...

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...

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...

Angular js unbind and bind dynamically not working

angularjs,angular-ngmodel,ng-bind
I have an 2 inputs with ng-model and two elements binding the two models, I want that when I click on a button it switch the bindings i a way that element 1 binds model 2 and element 2 bind model 1, it work perfectly, but when start changing models...

ng-model and value combination not working for input text box

javascript,angularjs,input,angular-ngmodel
I'm having two input text box. I need to combine the values entered in two text boxes and display it in the third. I'm able to display it if I use only the value in the third text box. Box 1: <input type="text" ng-model="entity.name"> Box 2: <input type="text" ng-model="entity.code"> Box...

AngularJS assign values to items in ng-repeat array using ng-model and retrieve those values

arrays,angularjs,angularjs-ng-repeat,angular-ngmodel
ok so this is turning out to be a little harder than expected. i have two arrays one for products and one for options. where the problem starts is when i try to give each product its own options array with its own scope, meaning when one option is selected...

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...

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...

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...

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...

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"...

ng-model in select box is not working correctly

javascript,angularjs,angular-ngmodel
I am using angular js to draw select boxes. <select ng-model="selected"> <option value="{{obj.id}}" ng-repeat="obj in values">{{obj.name}} </option> </select> selected id - {{selected}} Here the default selected is not initialized according to value selected. Have made a fiddle for the problem....

ngModelCtrl - $setViewValue without $setDirty();

javascript,angularjs,angularjs-directive,angular-ngmodel
I have a directive which manipulates the $viewValue of an input field via ngModelCtrl.$setViewValue() on blur. function _onFocus () { presentation = false; if(!ctrl.$isEmpty(ctrl.$modelValue)) { ctrl.$setViewValue(String(ctrl.$modelValue).replace(/\./, ',')); ctrl.$render(); } } Plunkr Since this is only an appearance thing, I wonder if there is the possibility of setting the ViewValue without...

ng-options filter by value in another dropdown

angularjs,angular-ngmodel,ng-options
This seems to be a really straight forward code, but I cannot figure out why it is not working. I want to filter the 'model' dropdown by selected 'make', Make: <select ng-model="makeng" ng-options="option.display for option in makes"> <option ng-disabled="true" ng-selected="true" value="">Select a make</option> </select> Model: <select ng-model="modelng" ng-options="option.display for option...

How to track behavior of ngModel array item using .directive

javascript,angularjs,directive,watch,angular-ngmodel
Hi everyone I'm use angularjs not so long time ago and now I have one issue related with this framework that i can't to solve. So the problem in next: I have few input fields that generate via ng-repeat: <div class="form-group" ng-repeat="(i, name) in name_list track by $index"> <div class="row">...

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',...

multiple forms ng-repeat - posting back the current $scope only, not whole object

angularjs,angularjs-scope,angularjs-ng-repeat,angular-ngmodel
I have multiple forms using ng-repeat. <div ng-repeat="individual in orderDetails track by $index"> <form ng-submit="saveDetails();"> <input ng-model="individual.order.statusText"> <button type="submit">Save changes</button> </form> </div> Here's an example of what's stored in my object, for each individual (IE - object) in OrderDetails. orderDetails { object{ foo {}, bar {}, order {} }, object{...

Can't change select option item angular

javascript,json,angularjs,html-select,angular-ngmodel
I have a select option like this: <select ng-init="filterSelected = getItems.data.key" ng-model="filterSelected" ng-options="data.key as data.label for data in getItems.data" ></select> In which i parse a json that returns me some results that shows as item in this select. This is not a problem, i can display the items but i...

Angular JS ng-model not initiating properly for the first time

javascript,angularjs,angular-ngmodel
I am using Angular JS ng-model to track the selected value of the select tag. here's the example http://jsfiddle.net/8853oxb1/3/ function ControllerA($scope) { $scope.optionsArray = [1,2,3,4,5]; $scope.optionsObject = {"India" : "IN" , "Singapore" : "SG", "Malaysia" : "MY", "Indonesia" : "INDY"}; } If, I go to a dropdown by using a...

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...

Change selected