ng-options

AngularJs - ng-options not binding after ajax call

爷,独闯天下 提交于 2019-12-10 04:06:39
问题 I try to change the selected index of ng-options after ajax call, but it won't change. //Html Section... <select id="fooId" ng-model ="foo.formula" ng-options="formulas as name for (formulas, name) in the_formula"></select> //End Html Section... //js file... //get list of formula from server... TheSource.Get.then(function(response){ $scope.the_formula = response.the_formula; }); //do something awesome, then.. //binding data from server... TheData.Get.then(function(response){ //binding the

AngularJS ng-options adds data type to option's value

浪尽此生 提交于 2019-12-09 13:16:19
问题 Trying to use the latest version (1.5.8) of AngularJS and ng-options to populate a dropdownlist. Issue is that it's adding the data type as well as the value, like so: <select class="possedetail ng-valid ng-dirty ng-valid-parse ng-touched" ng-model="Province" ng-options="p as p for p in provList"> <option value="string:ALBERTA" label="ALBERTA">ALBERTA</option> <option value="string:BRITISH COLUMBIA" label="BRITISH COLUMBIA">BRITISH COLUMBIA</option></select> I need string:Alberta'... This is

AngularJS - setting selected value of dropdown does not work

偶尔善良 提交于 2019-12-09 10:32:37
问题 I made a fiddle replicating my problem here: http://jsfiddle.net/U3pVM/2840/ As the title suggests, I can't set the selected value of a select populated using ng-options. I have searched and tried all possible solutions that I found. Any help or suggestions would be appreciated! HTML <div ng-app> <h2>Todo</h2> <div ng-controller="TodoCtrl"> <select ng-model="ddlRooms" ng-options="r.id as r.Name for r in Rooms"> </select> {{$scope.test}} </div> </div> Angular function TodoCtrl($scope) { $scope

Customize ng-options selection look

妖精的绣舞 提交于 2019-12-09 03:13:36
问题 I'm using a ng-options for a select dropdown menu. I would like to use different color for an option depending on a condition: select(ng-model='myCompany', ng-options='company.code as company.name for company in companies' **if company.active -> text-color=green**) Is it possible to do that? Edit (my jade code): form(role='form', name='addForm', novalidate, rc-submit="add()") .form-group div.row div.col-xs-12.col-md-3 select.form-control(ng-model='form.contract', ng-options='contract as

angularjs - Add multiple hard-coded options to select box with ng-options

流过昼夜 提交于 2019-12-08 16:07:19
问题 I have a select box that is populated with ng-options . I know you can add a default option manually, like so: <select ng-model="selectedAddress" ng-init="selectedAddress = selectedAddress || address_dropdown[0].value" ng-change="handleStoredAddressClick2()" ng-options="a.dropdown_display for a in address_dropdown" id="address_dropdown"> <option value="" ng-selected="selected">Add a new address</option> </select> Is there any way (in angular) to add multiple options? The client now wants to

angular select doesn't work without ng-model

妖精的绣舞 提交于 2019-12-08 15:53:25
问题 Does anyone know why in Angular, the select selector doesn't work without the ng-model? <select ng-model="bla_bla" ng-options="obj.value as obj.key for obj in languages"/> <select ng-options="obj.value as obj.key for obj in languages"/> The first line of code above will work while the second one will not work. Why ??? Thanks! 回答1: Using the select tag within an Angular app generates the ng-select directive, which is an HTML SELECT element plus angular data-binding. Looking in the Angular

AngularJs Get the value of the selected option

那年仲夏 提交于 2019-12-08 14:52:40
问题 How can i get the value of the selected option on the ng-change "ReadData" Template is an array of Title, Id, and body <select class="form-control" id="inputEmail" ng-change="ReadData(Template.Title)" ng-model="email.Template" name="inputEmail" ng-options="b.Id as b.Title for b in Template"> </select> 回答1: This might work: ng-change="ReadData(Template[$index].Title)" 回答2: Since your select is bound (by means of ngModel ) to email.Template , you can access it's value from there. E.g.: <select

angularjs - cascading selects use model data from first select

 ̄綄美尐妖づ 提交于 2019-12-08 12:12:55
问题 I'm attempting to get at the version data stored inside the server model, however, it's not playing ball. My assumption is that on load the initial data from the first select is not yet available because it hasn't really been selected (technically speaking). I tried to use trigger('click') whether this would help at all, but it did absolutely nothing. I can't seem to find any answers out there and I have a feeling I maybe tackling it from the wrong end. edit: Forgot to mention, if I have to

ng-model data is not binding for selected ng-option

会有一股神秘感。 提交于 2019-12-08 04:13:16
问题 HTML <select ng-model="selected1" ng-options="item.Name as item.Name for item in jobLineClassFSC" class="gridinputs"> </select> <select ng-model="selectedJobLineTypeFSC" ng-options="item.Name as item.Name for item in jobLineTypeFSC"> </select> <select ng-model="selectedJobLineSubTypeFSC" ng-options="item.Name as item.Name for item in jobLineSubTypeFSC"> I'm getting the result and display it properly; but the selected list is not getting bound to the ng-model and I don't know why. I

How might I implement conditional grouping in a Select element using angular?

爷,独闯天下 提交于 2019-12-08 04:09:11
问题 I would like to know if I can include additional logic in angular ng-options attribute for a Select element. In one case, I have a set of options that are flat and have no groupings associated with them. In another, I have multiple options that may have the same description, however their Id's vary because they are each grouped into categories. Based on the data sent over, I would like to display them as either grouped or not grouped. GROUPED: <select ng-model="tcCtrl.SelectedItem" ng-options