FAQ Database Discussion Community


How do I set ng-option model to the value of an object?

javascript,angularjs,ng-options
I'm pulling in an array of objects as $scope.templates. I'd like to be able to set $scope.item.steps (my select model name) to the value of template.steps for the selected option in my ng-options array. Is there an easy way to do this without having add extra controller logic? <select class="form-control"...

Hardcoded values in NG-OPTIONS with dynamic values from NG-REPEAT

angularjs,angularjs-ng-repeat,ng-options
Let's say we have this data and it's being returned by an API $scope.arrayOfStudentObjects = [ { name : 'Ashley', gender : 'female' }, { name : 'Tom', gender : 'male' }, { name : 'Scott', gender : 'male' } ]; Then the values that we put in < select...

Angularjs select value is undefined

angularjs,select,ng-options
Now I am trying to get the value from select dropdown, but it return undefined. The thing is in html level it works as expect, Here is my code: <div class='subcontent'> <input id="me" type="radio" class='choosemethod' ng-model="paymentmethod" value="Y"><label for="me" class='choosemethod'>Me</label> <input id="company" type="radio" ng-model="paymentmethod" value="N" class='choosemethod'><label for="company" class='choosemethod'>My Company</label><br/> <span class='helptext'>Who...

How to assign selected option's text to another model while using ng-options?

javascript,angularjs,select,model,ng-options
I can create a select tag and place data inside it. I can assign that select's selected option to a model but can't assign its text to another model. Here is example below and jsFiddle link html: <div ng-app> <div ng-controller="DemoCtrl"> <select ng-model="customerId" ng-options="item.id as item.name for item in content"...

ng-options default value from external json file

angularjs,ng-options
I have a select data-ng-model="layout" ng-options="layout.url as layout.name for layout in layouts" populated from an external json file: { "metaDescription": "My website description", "metaKeywords": "keyword1, keyword2", "siteTitle": "My Company", "pageTitle": "Welcome ", "layout": [ { "name": "Cerulean", "url": "cerulean" }, { "name": "Cosmo", "url": "cosmo" }, { "name": "Cyborg", "url":...

AngularJS ng-option get index

javascript,angularjs,ng-options,angularjs-ng-options
I'm making a playlist option in the project I'm working on and I'm trying to get a dropdown for all the videos in the list. which is easy <select ng-options="vid.Id for vid in playList.Videos track by video.Id" ng-model="selected" class="browser-default"></select> but this shows a drop down of the Id's, but now...

Pre-select option form ng-options list

javascript,angularjs,drop-down-menu,ng-options
I'm trying to preselect a item in the list which is generated by ng-options directive. Could someone please tell me whats happening in the plunker? http://plnkr.co/edit/GTnR76HEnB5NxQRe484m?p=preview <head> <script src="http://ajax.googleapis.com/ajax/libs/angularjs/1.0.6/angular.min.js"></script> <script> function MyCntrl($scope) { $scope.prop = { "type": "select", "name": "Service", "values": [{ 'name': "Service 1" }, { 'name': "Service 2"...

How to set the initial ng-model value for a

javascript,sql-server,angularjs,unicode,ng-options
Hello I've ran into an issue that is stumping me: So I have an ngOption that loops through and displays unicode symbols <select class="form-control symbolSelect" ng-model="input.loadSymbol" ng-options="d as d.TagShpUTF for d in loadSymbols" ng-change=""></select> Here is an example jsFiddle showing it working: http://jsfiddle.net/tjm9a6o2/ I set up the datasource to have...

How to define ng-options selected value and assign this to model?

javascript,angularjs,model,ng-options
I have a data like this which i compile to select options and inside it selected value defined as defaultValue: 1 content: [ { value: "Bireysel", key: "1", defaultValue: 0 }, { value: "Kurumsal", key: "2", defaultValue: 1 }, { value: "Bireysel & Kurumsal", key: "3", defaultValue: 0 } ]...

AngularJS doesn't update selected option

angularjs-scope,ng-options,angularjs-ng-options
I have the following problem. In my controller I have this variables: $scope.types = [ {id: 0, name: $translate.instant("FIRST")}, {id: 1, name: $translate.instant("SECOND")}, {id: 2, name: $translate.instant("THIRD")}, {id: 3, name: $translate.instant("FOURTH")} ]; $scope.itemtype = {}; $scope.itemtype = $scope.types[0]; In my view I have this select <select class="form-control" required ng-model="itemtype" ng-options="item...

Angular ng-options for bounded select elements

angularjs,select,options,ng-options
I'm almost there but stuck on one little detail. I can't seem to get the "name" property of the selected Car Make's "Car Model" to actually show up on the select menu. At the moment, it seems to be showing the correct number of options, but the options are visibly...

orderBy not working properly on ng-options

angularjs,ng-options
everything is working fine, but with an anomaly of 1 month. I want to show months in descending order, ng-options="i as payrollRule.prd_date_display for (i,payrollRule) in payrollRules | orderBy:'-time'" with JSON http://jsoneditoronline.org/?id=5180c8005b1072418925a0f01968bdffenter link description here but as you see in img, only 01 Apr 2014 is coming at 2nd position instead...

Object comparison in ng-options

angularjs,ng-options
I have a select that I populate using ng-options and ng-model. The problem I have is that initially, the model is a copy of the data within the ng-options so my initial state is a blank option rather than the correct state of ng-model. How can I make it so...

Hide selected option in other list using ngOptions in AngularJS

javascript,arrays,angularjs,ng-options,angularjs-ng-options
Hoping someone can help with this challenge. I have 1 array of airports being used in two build separate dropdowns. <select data-ng-model="flightData.origin" data-ng-options="airport.code as airport.label for airport in flightData.airports" name="origin"></select> and <select data-ng-model="flightData.destination" data-ng-options="airport.code as airport.label for airport in flightData.airports" name="destination"></select> Both of these lists obviously have the same options....

Angular ng-options remove blank option and select the first option only

javascript,angularjs,html5,ng-options
I am using AngularJS to populate my select options content dynamically from an array of objects in my controller. My objects has a property named userProfileName. How would it be possible to remove the blank option that I am getting at the top? Also, I would want to select the...

Cannot bind ngResource to ngOptions

angularjs,ng-options,ngresource
I have a select element, and I want it populated with the result of a call to a resource via ngResource. <select chosen="" required data-ng-model="coolStuffSelected" data-ng-options="stuff for stuff in coolStuff" class="chosen-select input-md"></select> In my Controller I have CoolStuffResource.query(function(result){ $scope.coolStuff = result; console.log(JSON.stringify($scope.coolStuff)); // prints ["foo","bar","gaz","waka"] }); I see the result...

AngularJS ng-options

angularjs,angularjs-scope,ng-options,angularjs-ng-options
I have this select in AngularJS: <select id="objectId" name="seccionId" class="form-control" ng-model="arguments.seccion" data-ng-options="item.id as item.valor for item in arguments.objects" required></select> I like to save both values in scope, but I only save one value. Any form to save both values? Thanks!!!...