FAQ Database Discussion Community


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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Nested/embedded $resources in ngRepeats

angularjs,angularjs-ng-repeat,angular-ngmodel,angular-resource
My API populates some nested models. Using a shopping example, when you query orders, the items property is populated with the description and quantity instead of returning just the item IDs. orders: [ {_id: 1, items: [ {_id: 100, description: "apple", // from lookup in the Items table quantity: 4...

Change selected