ng-options

ng-options and unique filter not displaying angular.js

与世无争的帅哥 提交于 2019-11-26 18:35:01
问题 In my javascript I have an array $scope.quoteList = [ { select: false, laymansDescription: "Nathan", quoteNumber: "ING-70440-21", version: "02", quoteDate: "Feb 5,2013", expirationDate: "Aug 5,2013", internalNotes: "This quote is using test data", }, { select: false, laymansDescription: "Mitch", quoteNumber: "ING-70440-01", version: "02", quoteDate: "Feb 5,2013", expirationDate: "Aug 5,2013", internalNotes: "This quote is using test data", }, { select: false, laymansDescription: "Stephen",

Angularjs ng-options using number for model does not select initial value

隐身守侯 提交于 2019-11-26 17:35:38
问题 I'm trying to use ng-options with a <select> to bind a numeric integer value to a list of corresponding options. In my controller, I have something like this: myApp.controller('MyCtrl', function() { var self = this; var unitOptionsFromServer = { 2: "mA", 3: "A", 4: "mV", 5: "V", 6: "W", 7: "kW" }; self.unitsOptions = Object.keys(unitOptionsFromServer).map(function (key) { return { id: key, text: unitOptionsFromServer[key] }; }); self.selectedUnitOrdinal = 4; // Assume this value came from the

ng-options with disabled rows

試著忘記壹切 提交于 2019-11-26 16:15:19
Is it possible to use ng-options that it will render into disabled rows based on criteria? this: <select ng-options="c.name group by c.shade for c in colors"> maybe possible to turn into something like this: <select ng-options="c.name group by c.shade for c in colors | disabled(c.shade)"> and let's say via a filter that could return disabled='disabled' for all the colors that have shade = "dark" <select> <optgroup label="dark"> <option value="0" disabled="disabled">black</option> <option value="2" disabled="disabled">red</option> <option value="3" disabled="disabled">blue</option> </optgroup>

ng-options with simple array init

淺唱寂寞╮ 提交于 2019-11-26 15:09:46
问题 I'm a little bit confused with Angular and ng-options . I have a simple array and I want to init a select with it. But, I want that options value = label. script.js $scope.options = ['var1', 'var2', 'var3']; html <select ng-model="myselect" ng-options="o for o in options"></select> What I get: <option value="0">var1</option> <option value="1">var2</option> <option value="2">var3</option> What I want: <option value="var1">var1</option> <option value="var2">var2</option> <option value="var3"

Use filter on ng-options to change the value displayed

大城市里の小女人 提交于 2019-11-26 12:57:58
问题 I have an array of prices ( 0 , 0.99 , 1.99 ... etc) that I want to display in <select> . I want to use Angular\'s ng-options like this <select ng-model=\"create_price\" ng-options=\"obj for obj in prices\"/> As it is displayed above it will generate a selection of 0 , 0.99 , 1.99 ... But I want to use a filter in the code such that every time the word \'prices\' is presented (or something like that), the code will run a function to change the float numbers to strings and present ( free , 0

ng-options with disabled rows

房东的猫 提交于 2019-11-26 12:15:28
问题 Is it possible to use ng-options that it will render into disabled rows based on criteria? this: <select ng-options=\"c.name group by c.shade for c in colors\"> maybe possible to turn into something like this: <select ng-options=\"c.name group by c.shade for c in colors | disabled(c.shade)\"> and let\'s say via a filter that could return disabled=\'disabled\' for all the colors that have shade = \"dark\" <select> <optgroup label=\"dark\"> <option value=\"0\" disabled=\"disabled\">black<

Angularjs: ng-options group by

眉间皱痕 提交于 2019-11-26 11:29:01
问题 I have this one level tree situation: <select ng-model=\"tipost\" ng-options=\"tip.DESC group by tip.TIPIS for tip in tipall\"><br> </select> where the json is: [ {\"ID\":\"1\", \"IDPARENT\":\"0\", \"TIPIS\":\"\", \"DESC\":\"GroupName1\"}, {\"ID\":\"2\", \"IDPARENT\":\"1\", \"TIPIS\":\"GroupName1\", \"DESC\":\"CHILDNAME1\"}, {\"ID\":\"3\", \"IDPARENT\":\"0\", \"TIPIS\":\"\", \"DESC\":\"GroupName2\"} ] the problem is that this creates the optgroups with their children but repeats the roots too

key-value pairs in ng-options

99封情书 提交于 2019-11-26 08:07:47
问题 I need to use an associative array as data source for my select options using AngularJS. Is it possible to use an array like this? { \"key1\": \"val1\", \"key2\": \"val2\", \"key3\": \"val3\", ... } and get something like this: <select> <option value=\"key1\">val1</option> <option value=\"key2\">val2</option> <option value=\"key3\">val3</option> ... </select> I read docs, but I can\'t understand how to achieve this. 回答1: use ng-option : <select ng-model="blah" ng-options="key as value for

ng-change get new value and original value

元气小坏坏 提交于 2019-11-26 08:02:11
问题 I\'m using ng-options to select values from a pulldown. I\'d like to be able to compare the old value to the new value. ng-change works well for grabbing the new value of the pull down, but how can I get both the new value and the original value? <select ng-change=\"updateValue(user)\" ng-model=\"user.id\" ng-options=\"user.id as user.name for user in users\"></select> For instance, let\'s say I wanted the controller to log, \"Your former user.name was BILL, your current user name is PHILLIPE