ng-options

Angular injects “string:” before value in ng-options

人走茶凉 提交于 2019-11-30 23:23:59
I have a ng-options list defined with a HTML select element such as: <select required="required" ng-model="vm.selectedOption" ng-options="item.name as item.label for item in vm.options"> <option value="">Select an option</option> </select> This however results in the following HTML: <option value="string:VALUE" label="Option Name">Option Name</option> I am using Angular version 1.4.8, does anyone have a solution how to solve the string: issue or at least can explain to me why this is occurring? The vm.options array looks like this: [ { "name": "INFILL_AUTOMATIC", "label": "Automatic" }, {

Get old value and new value from dropdown

泄露秘密 提交于 2019-11-30 20:32:51
I'm trying to simply get the previous value, and the newly selected value from a drop-down. In this example, the drop-down is pre-populated with the current group the user is assigned. When the drop-down is changed, I want to be able to return the old value and the new value. I can already get the old value, but I don't know how to return the new value. Controller Code: // User Object userAccess = [{"user_name":"dodsosr11", "group_level":1, "user_id":500, "group_id":10, "group_name":"Conferences_Admins"}, {"user_name":"keatikj09", "group_level":1, "user_id":250, "group_id":10, "group_name":

ng-options with object data source

血红的双手。 提交于 2019-11-30 16:46:35
I'm struggling to understand how ng-options works with a data source. I've read the docs and I feel like I'm doing exactly what is required, but I still get problems when attempting. <!DOCTYPE html> <html ng-app="app"> <head> <script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.1.5/angular.min.js"> </script> <link rel="stylesheet" href="style.css" /> <script type="text/javascript"> angular.module('app', []) .controller('IndexCtrl', ['$scope', function($scope) { $scope.types = { 1: "value1", 2: "value2", 5: "value3" }; }]); </script> </head> <body ng-controller="IndexCtrl"> <select ng

AngularJS dynamic ng-option to link two drop downs

会有一股神秘感。 提交于 2019-11-30 16:39:38
Can anyone help me with a ng-option issue, I am trying to have ng-option created dynamically. What I am doing is pretty complex but I tried to explain it in following link I have two drop downs the first one has values like county, municipality and district based on whats selected in first drop down box the second drop down box will have either county or municipality or districts populated. but the trick is that the json for county or district or municipality have different structure so the ng-option for the second drop down has to be dynamic. please help <div ng-controller="myCtrl"> <select

ngOptions “track by” expression

老子叫甜甜 提交于 2019-11-30 16:38:34
问题 I am trying to use the 'track by' expression to track selections by id, in an array of objects. However, I can't seem to make it work like I think it works. //ids from server $scope.serverDTO = ['1','2','3']; //composed objects from the ID set $scope.composedData = [{id:1,name:"test"},{id:2,name:"test"},{id:3,name:"test"}]; <!-- select box --> <select ng-model="serverDTO" ng-options="item as item.name for item in composedData track by item.id"></select> So based on the documentation I though

Using <select> and <option> in AngularJS

淺唱寂寞╮ 提交于 2019-11-30 09:23:25
问题 I have this anchor tag and i change my view depending on the date coming from the object. I am trying to change it to be a select option but it is not working the way i am doing it. This is anchor tag syntax: <a href="#" ng-repeat="item in home.prData" ng-click="home.selectedPr = item; $event.preventDefault(); $event.stopPropagation();">{{item.date}}</a> I am trying to change it to be like that when i use select option <select st-search="{{item.date}}" class="show-tick form-control dropdown

AngularJs conditional display for ng-options

一个人想着一个人 提交于 2019-11-30 08:53:53
I've been searching for a few hours now and I can't seem to find the answer for my problem anywhere. I remember that I was able to implement it before but for some reason I lost the code and I can't seem to remember what I did to make it work. I'm trying display data from an array in a select box using ng-options. That one I have no problems with. What I need to implement is that only certain array values will be displayed/included in the select box. My data is as follows: $scope.chartList = [ { "id" : 1, "name" : "chart 1", "order" : 1, "active" : false }, { "id" : 2, "name" : "chart 2",

Filter ng-options from ng-options selection

心不动则不痛 提交于 2019-11-30 03:58:15
I'm hoping to solve three problems... In my app page I have one select for states and another for counties. For states I have: <select ng-model="filter.stateID" ng-options="item.stateID as item.state for item in st_option"> </select> Data: [ { state="California", stateID="5"}, { state="Arizona", stateID="3"}, { state="Oregon", stateID="38"}, { state="Texas", stateID="44"}, { state="Utah", stateID="45"}, { state="Nevada", stateID="29"} ] For my County select I have: <select ng-model="filter.countyID" ng-options="item.countyID as item.county for item in co_option"> </select> Data: [ { county=

Get old value and new value from dropdown

浪尽此生 提交于 2019-11-30 03:54:18
问题 I'm trying to simply get the previous value, and the newly selected value from a drop-down. In this example, the drop-down is pre-populated with the current group the user is assigned. When the drop-down is changed, I want to be able to return the old value and the new value. I can already get the old value, but I don't know how to return the new value. Controller Code: // User Object userAccess = [{"user_name":"dodsosr11", "group_level":1, "user_id":500, "group_id":10, "group_name":

ng-options with object data source

落花浮王杯 提交于 2019-11-30 00:05:35
问题 I'm struggling to understand how ng-options works with a data source. I've read the docs and I feel like I'm doing exactly what is required, but I still get problems when attempting. <!DOCTYPE html> <html ng-app="app"> <head> <script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.1.5/angular.min.js"> </script> <link rel="stylesheet" href="style.css" /> <script type="text/javascript"> angular.module('app', []) .controller('IndexCtrl', ['$scope', function($scope) { $scope.types = { 1: